forked from adampatterson/Tentacle
-
Notifications
You must be signed in to change notification settings - Fork 1
Storing queries for later
Adam Patterson edited this page Dec 18, 2012
·
1 revision
It is possible to store SELECT, UPDATE, and DELETE queries for use at a later time:
// Select the table
$table = db('mytable');
// Construct the query
$query = $table->select('*')
->where('id','<=',10)
->order_by('id','DESC');
// Later... Execute the query
$query->execute();
Notice that we left the execute()
method off of the query when we constructed it. Then later to run that query we simply use the execute()
method on the $query object.
Note that you cannot store shorthand SELECT and DELETE queries for later use. For example you could not store this query:
// Select the table
$table = db('mytable');
$table->select('name','!=','Evan');
But you could store the full sized version of that query:
// Select the table
$table = db('mytable');
$query = $table->select('*')
->where('name','!=','Evan');