[Phpmyadmin-devel] about $common_functions
marc at infomarc.info
Tue Jul 3 17:24:44 CEST 2012
Le 2012-07-03 10:46, Chanaka Dharmarathna a écrit :
> Hi Marc,
> Ok, so what do you think of this code snippet:
>> $query = $insert_command . 'INTO '
>> . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['db']) . '.'
>> . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['table'])
>> . ' (' . implode(', ', $query_fields) . ') VALUES ('
>> . implode('), (', $value_sets) . ')';
>> Does this follow the singleton principle?
> As I think this doesn't break the singleton principle since we are not
> creating two objects.
> Since the private constructor always give the existing PMA_CommonFunctions
> object if there exist any, no more objects are created.
> Actually why I used that $common_functions variable is, reducing the line
> length and if there are frequent occurrence inside procedural code or
> function, its easy to use a variable than this lengthy code.
> As well we have discussed to reduce the use of globals.
> Please make me correct if I did any wrong.
> Regards !
Thanks Chanaka for the clarification. I think that using a local
$common_functions is a good idea and we should use it most (all?) of the
times: it makes reading code easier if we have just one way of accessing
More information about the Developers