$query = "SELECT * FROM table WHERE first_name = ? AND last_name = ?"; $this->db->query($query, array("John", "Doe"));
Harro Verton wrote on Tuesday 12th of July 2011:Not documented yet, but you might be able to do
$first = 'John'; $last = 'Doe'; $query = DB::query("SELECT * FROM table WHERE first_name = :first AND last_name = :last"); $query->bind(':first', $first)->bind(':last', $last)->execute();Note that bind() works by reference, so if you change the value of $first between the bind() and the execute() call, this change is reflected in the query. If you don't want that, use param() instead, which works by value. Both bind() and param() will escape the values before placing it in the query.
$result = \DB::select()->where('first_name', '=', 'John')->where('last_name', '=', 'Doe')->from('table')->execute();
$first = 'John'; $last = 'Doe'; $query = DB::query("SELECT * FROM table WHERE first_name = :first AND last_name = :last"); $query->bind(':first', $first)->bind(':last', $last)->execute();Note that bind() works by reference, so if you change the value of $first between the bind() and the execute() call, this change is reflected in the query. If you don't want that, use param() instead, which works by value. Both bind() and param() will escape the values before placing it in the query.
It looks like you're new here. If you want to get involved, click one of these buttons!