[TYPO3-dev] Stupid Stupid Stupid

Peter Russ peter.russ at 4many.net
Tue Jun 24 09:45:01 CEST 2008


--- Original Nachricht ---
Absender:   Fr. Simon Rundell SCP
Datum:       24.06.2008 09:36:
>  I freely admit to you all that I've not been good at coding extensions
> using the API, and this really basic and stupid question hopefully will mark
> a turn in that:
> 
> Previously, to extract data into an array, I would have written:
> 
>        $sql="SELECT * FROM ".$data["database"]." WHERE
> uid=".$data["drpRecordSelect"];
>        $newdata = $this->get_data($sql); // this is a function which queries
> and returns the array
> 
> and I know I should use exec_SELECTquery, so
> 
> global $TYPO3_DB;
> 
>         $newdata=$TYPO3_DB->exec_SELECTquery('*', $data["database"],
> 'uid='.$data["drpRecordSelect"], '', '', '');
> 
> so why isn't it returning anything? Am I not referencing the database object
> right (should it be $GLOBALS["TYPO3_DB"]) or is there something else
> fundamental in that. Sorry fpr asking such a basic question, but if I crack
> this then I promise I'll write nice secure, API-wrapped queries in future.
> :-)

1) Use $GLOBALS['TYPO3-DB]->exec_SELECTquery
2) This should return a pointer to the recordset that you can walk 
through with res=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($rec);
3) Read the API doc ;-)

Regs. Peter

-- 
Fiat lux!
Docendo discimus.
_____________________________
4Many® Services
XING: http://www.xing.com/go/invuid/Peter_Russ




More information about the TYPO3-dev mailing list