[TYPO3] problem with sql query

Ries van Twisk typo3 at rvt.dds.nl
Sun Feb 12 15:30:45 CET 2006


Daniel Pötzinger wrote:

>Ries van Twisk wrote:
>  
>
>>Daniel Pötzinger wrote:
>>
>>    
>>
>>>stem wrote:
>>> 
>>>
>>>      
>>>
>>>>hello,
>>>>
>>>>i'm sure it is a stupid thing, however it drives me crazy.
>>>>
>>>>i have the following sql query in my t3-extension:
>>>>$query = 'SELECT storage_pid FROM pages WHERE uid = 
>>>>'.$GLOBALS['TSFE']->id;
>>>>$storagePid = mysql(TYPO3_db, $query);
>>>>
>>>>therewith i would like to receive the storage pid of the page, where 
>>>>my extension is used in order to save the form entries in the 
>>>>corresponding sys_folder.
>>>>
>>>>  
>>>>        
>>>>
>>>Hello
>>>
>>>1)
>>>It would be better to use the DBAL (see t3lib/class.t3lib_db.php)
>>>e.g.
>>>$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(...)
>>>$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)
>>>
>>>2.) There is no need for this select, T3 FE did already select these 
>>>values:
>>>Array:
>>>$GLOBALS['TSFE']->page
>>>ders.de/cgi-bin/mailman/listinfo/typo3-english
>>> 
>>>
>>>      
>>>
>>Yes... NEVER EVER EVER NEVER EVER use direct mysql calls :) better use 
>>DBAL.
>>
>>However the above is also the wrong way to get the storage PID.
>>
>>$pids = $GLOBALS["TSFE"]->*getStorageSiterootPids*()
>>
>>
>>    
>>
>You are right using available function is always better than accessing 
>variables. (cause of later changes and maintainability..)
>
>But however:
>I just depends on what you want. This function traverses the rootline 
>and returns the first found storage pid and siteroot.
>
>It maybe not the expected result if I only want the storagepid from the 
>curent site. (and maybe want to use $GLOBALS['TSFE']->id if no storage 
>pid is set for the current site.)
>  
>
Personally I think that that should be the behavure...
If one extension behaves differently from a other extension. Then it's 
really hard for an regular admin to understand how extension in general 
work, where is data stored and retreived.... This is as far as I know we 
have a starting point for an extension to 'start' from a other point, 
also here is an API for it...

However, this is I think a bit gray area and extension developers do 
have to much freedom how to do things....

well... as long it'sa documented the right way....

>Greetings
>
>
>_______________________________________________
>TYPO3-english mailing list
>TYPO3-english at lists.netfielders.de
>http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
>  
>




More information about the TYPO3-english mailing list