Typically, a statement object is returned by the
query() method of the database Adapter class.
This method is a general way to prepare any SQL statement.
The first argument is a string containing an SQL statement.
The optional second argument is an array of values to bind
to parameter placeholders in the SQL string.
Example 215. Creating a SQL statement object with query()
$stmt = $db->query(
'SELECT * FROM bugs WHERE reported_by = ? AND bug_status = ?',
The statement object corresponds to a SQL statement that has been prepared, and executed once with the bind-values specified. If the statement was a SELECT query or other type of statement that returns a result set, it is now ready to fetch results.
You can create a statement with its constructor, but this is less typical usage. There is no factory method to create this object, so you need to load the specific statement class and call its constructor. Pass the Adapter object as the first argument, and a string containing an SQL statement as the second argument. The statement is prepared, but not executed.
Example 216. Using a SQL statement constructor
$sql = 'SELECT * FROM bugs WHERE reported_by = ? AND bug_status = ?';
$stmt = new Zend_Db_Statement_Mysqli($db, $sql);