On Tue, Jun 19, 2012 at 3:23 PM, Chanaka Dharmarathna <pe.chanaka.ck@gmail.com> wrote:


On Tue, Jun 19, 2012 at 2:37 PM, Rouslan Placella <rouslan@placella.com> wrote:
On 19/06/12 09:35, Chanaka Dharmarathna wrote:
> On Mon, Jun 18, 2012 at 6:36 PM, Chanaka Dharmarathna<
> pe.chanaka.ck@gmail.com>  wrote:
>
>>
>>
>> On Sun, Jun 17, 2012 at 4:39 PM, Marc Delisle<marc@infomarc.info>  wrote:
>>
>>> Le 2012-06-16 00:26, Chanaka Dharmarathna a écrit :
>>>
>>>> Hi All,
>>>>
>>>> I have already create a class for display_tbl.lib.php
>>>> andPMA_getDataCellForBlobField() in master used the
>>>> PMA_mimeDefaultFunction() function as a global function.
>>>> EX :
>>>> $str = 'PMA_mimeDefaultFunction';
>>>> $str($parameters);
>>>>
>>>> I have moved the PMA_mimeDefaultFunction() from display_tbl.lib.php (in
>>>> master) to common.lib.php file due to the way it has used inside
>>>> display_tbl.lib.php.
>>>>
>>>> Now I'm implementing class behavior in common.lib.php file.
>>>> So can anyone tell me a file, which contain global function, to where I
>>>> should again move this PMA_mimeDefaultFunction().
>>>>
>>>> Regards !
>>>
>>> Chanaka,
>>> I believe that this function should not be global, as it's only called
>>> from other functions in libraries/DisplayResults.class.php, right?
>>>
>>> --
>>> Marc Delisle
>>> http://infomarc.info
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> _______________________________________________
>>> Phpmyadmin-devel mailing list
>>> Phpmyadmin-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
>>>
>>
>> Hi Marc,
>>
>> Sorry for little bit delay to respond.
>> I first try to use this function while it is inside the PMA_DisplayResults
>> class.
>> But if there is any field with transformations, it does not work properly.
>>
>> So that put it as a global function.
>> But I can again consider on that after completing the implement class
>> behavior of common.lib.php file
>> For just now I move PMA_mimeDefaultFunction() function to core.lib.php
>> file.
>>
>>
>> Regards !
>> --
>> ____________________________________
>>
>> Chanaka Indrajith
>> Bsc.Computer Engineering Undergraduate
>> Faculty of Engineering
>> University of Peradeniya
>> Sri Lanka
>> ____________________________________
>>
>>
> Hi Michal,
>
> There are many places which are using functions in common.lib.php file.
> After implement the class behavior for this file, all the other places need
> to call those functions using an object of PMA_CommonFunctions class.
> Even in the same file I may need to create several objects of the
> PMA_CommonFunctions class. (files with global functions)
>
> So I' thinking of using global variable (in $GLOBALS super global array) to
> store an object of PMA_CommonFunctions class and introduce a global
> function (may be under core.lib.php) to get that object by checking whether
> the global variable is set or not.
> So that even inside the procedural code segments, that function can be used.
> Its highly appreciated if you can give me your feedback on this approach.
>
> Regards !


What you seem to want is a singleton [0]. In a few words: the
constructor is private, the instance is in a static variable and a
public getInstance method allows access to the instance. You can also
have a look at the PMA_Response class for a concrete example.

Bye,
Rouslan

[0]: http://en.wikipedia.org/wiki/Singleton_pattern

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Phpmyadmin-devel mailing list
Phpmyadmin-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel

Hi Rouslan,

Thanks for your quick and valuable information.
Singleton pattern definitely use only one object and it save the memory.
I'll use that.


Regards !
--
____________________________________

Chanaka Indrajith
Bsc.Computer Engineering Undergraduate
Faculty of Engineering
University of Peradeniya
Sri Lanka
____________________________________


Hi Michal,

I almost did the modifications related to introduce class behavior of common.lib.php file.
It is quite time consuming task since there are lot of files to do the minor modifications.

Now I'm facing to a problem.
Due to this changes code has not working properly. (I didn't commit the code yet since it is not working)
Is there any log file or something where we can see code is breaking?
Since this is not just one file its very hard to find out the errors.
Looking for suggestions to debug this code.

Regards !
--
____________________________________

Chanaka Indrajith
Bsc.Computer Engineering Undergraduate
Faculty of Engineering
University of Peradeniya
Sri Lanka
____________________________________