[TYPO3-dev] Annoyed by the use of $GLOBALS['TYPO3_DB']
ries van Twisk
typo3 at rvt.dds.nl
Fri Sep 19 20:03:16 CEST 2008
On Sep 19, 2008, at 12:51 PM, Steffen Kamper wrote:
> ries van Twisk schrieb:
>>
>> On Sep 19, 2008, at 12:17 PM, Steffen Kamper wrote:
>>
>>> Benjamin Mack schrieb:
>>>> Hey all,
>>>>
>>>> when I'm developing extensions, I find it very annoying to use
>>>> $GLOBALS['TYPO3_DB'] all the time, and it makes the code not so
>>>> readable
>>>> anymore.
>>>>
>>>> What do you think of having a reference to the
>>>> $GLOBALS['TYPO3_DB'] in
>>>> every instance of pi_base? Similar to what we have with div/lib...
>>>>
>>>> $this->DB->exec_selectQuery
>>>>
>>>> what do you think?
>>>>
>>>>
>>>
>>> Hey Benni,
>>>
>>> +1. It doesn't break anything as it can also be accessed with
>>> GLOBALS,
>>> and DB is used so often ...
>>>
>>
>> Would it be better to make a static function that return a DB object
>> rather then creating a variable for it??
>>
>> something like $db = t3lib_db->getDB();
>> Then you can use $db in your extension...
>>
>>
>> regards, Ries van Twisk
>>
> Hi Ries,
>
> this is possible anyway like
> $db =& $GLOBALS['TYPO3_DB'];
>
> vg Steffen
good catch, not sure if they & is needed... aren't objects always
returned by reference???
Anyways, I am against creating a other variable where there are better
solutions.
Ries
More information about the TYPO3-dev
mailing list