[TYPO3-mvc] complex queries

Cornelius Illi cornelius.illi at student.hpi.uni-potsdam.de
Thu Apr 29 00:22:33 CEST 2010


Thanks everyone for support!
However I got some problems when working with $query->statement():
I also want to have the possibility to count rows (e.g. for pagination).
I therefore have a Paginator-Class that gets a Query 
(*Tx_Extbase_Persistence_Query).

I cannot call count using statement (see Typo3DbBackend.php #241)
Therefore I build something like this:
*
if($query->getConstraint() instanceof 
Tx_Extbase_Persistence_QOM_StatementInterface) {
     $res = array ("count" => 
$query->execute()->getRows()->nextRow()->getValue("count(*)") );
} else {
     $res = array ("count" => $query->count() );
}

To be able to do so, I need a method in Query.php called getConstraint 
that returns $this->constraint.
Is there a possibility that this getter could be integrated - constantly!

Cheers & good night,

Cornelius


Am 28.04.2010 11:13, schrieb Sebastian Kurfürst:
> Hey,
>
>    
>> I haven't had a look if extbase is taking care of it, but please note
>> that you should never ever use unescaped/unquoted POST/GET vars in
>> queries due to the risk of SQL injections etc.
>>      
> Exactly. You can use stored procedures for that:
> $this->statement('SELECT * FROM foo WHERE title=%', array('My title'));
>
> Greets,
> Sebastian
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>    



More information about the TYPO3-project-typo3v4mvc mailing list