->query() – Envoie une requête


void $DB_DataObject->query ( string $string )


Envoie une requête à la base de données. Vous devriez penser que l'utilisation de plusieurs appels aux méthodes whereAdd et orderBy n'est pas forcément nécessaire, et qu'il est plus simple d'écrire simplement la requête, question de rendre le code plus propre et plus court.


  • string $string - Requête SQL


This function can not be called statically.


Requêtes sur une base de données

= new DataObjects_Person;
$person->query("SELECT * FROM {$person->__table} WHERE id > 12 ORDER BY id");
while (
$person->fetch()) {
Advanced Filters - ::
query(), ::
SelectAdd(), ::
whereAdd(), ::
Limit(), ::
OrderBy(), ::
GroupBy(), (Previous)
Libère les ressources (Next)
Last updated: Sun, 29 Aug 2010 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: didier.galland@gmail.com
"LIMIT" instruction is ignored if present in the query string passed to query(). You must set explicitly your limit by $dataObject->limit(0,5)

I suppose it's a bug, not a feature.

//this won't work as expected
$dataObject->query('SELECT * FROM my_table LIMIT 0,5');//10000 records in my_table

$res[]=$dataObject->name;//loops of 10 000 iterations

To obtain only 5 results, you must write :
$dataObject->query('SELECT * FROM my_table');//10000 records in my_table
Note by: delatbabel@spamgourmet.com
Undocumented features in query:

->query('BEGIN'); causes a begin transaction
->query('COMMIT'); causes a commit
->query('ROLLBACK'); causes a rollback

... for databases that support it.