[TYPO3-dev] Stupid Stupid Stupid

Popy popy.dev at gmail.com
Tue Jun 24 10:26:18 CEST 2008


Try exec_SELECTgetRows ;)

2008/6/24 Franz Holzinger <franz at fholzinger.com>:

> Hello Fr. Simon,
>
> >  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.
>
> See file t3lib/class.t3lib_db.php line 229 (TYPO3 4.2.1):
>
> ...
>  * @return      pointer         MySQL result pointer / DBAL object
>         */
> function
>
> exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy='',$orderBy='',$limit='')
> {
>
>
> So you should have written instead
>
> $res=$TYPO3_DB->exec_SELECTquery('*',
> data["database"],'uid='.intval($data["drpRecordSelect"]));
> $newdata = $TYPO3_DB->sql_fetch_assoc($res);
> $TYPO3_DB->sql_free_result($res);
>
>
> Database is not a good key name for a database table array.
>
> - Franz
>
>
>
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
>




More information about the TYPO3-dev mailing list