[Typo3-dev] Building MySQL queries with selectConf array
Ingmar Schlecht
ingmars at REMOVETHISweb.de
Fri Aug 29 14:21:07 CEST 2003
Sacha Vorbeck wrote:
> in the news and faq plugin MySQL queries are glued together with an
> array which is then passed to a function.
>
> The array is filled like this:
> $selectConf["where"] = "1=1 ".$where;
> $selectConf["orderBy"] = "title";
> $selectConf["where"].=" AND category=".$this->catExclusive;
>
> and is then passed to a function:
> $query = $this->cObj->getQuery("tx_faq_faq",$selectConf);
>
> The only chance I see adding a limit to the query is:
> $query .= " LIMIT 0,5";
>
> Is there another way? Maybe something like $selectConf["limit"] = "0,5";
> (which doesn`t work).
>
> It seems that the getQuery() function always selects all fields. Is
> there a way to restrict the query only to certain fields of a table?
>
> I wanted to take a look at the function getQuery() but I couldn`t find
> it.
OK, just read this:
Robert Lemke wrote:
> Just generate the TS in your script and use one of the cObj
> functions
!!!
> (see class.tslib_content.php). Try this:
>
> $lConf = array ();
> $lConf["params"] = 'hspace=1 vspace=1';
> $lConf["file."]["maxW"] = 100;
> $lConf["file"] = 'uploads/'.$blob_field_containing_filename;
> $imgCode = $this->cObj->cImage($lConf["file"],$lConf);
So what does that mean?
It means you can call any function/cObject or anything which is
mentioned in the TSRef by calling it directly from PHP, and setting the
TypoScript which is normallybpassed to the function, as the conf array.
Now, in your case, you are attempting to use the query function.
In the TSRef it is called "select".
See:
http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=318&cHash=a98cb4e7e6
And there you'll find a nice reference of what's possible and what isn't.
Sacha Vorbeck wrote:
> I still don`t understand what the reference to $this-cObj really means.
$this->cObj refers to the class tslib_cObject!
Read it carefully until the end ;-) and you'll understand a lot more
about Typo3!
- Ingmar
More information about the TYPO3-dev
mailing list