PDO::prepare

(no version information, might be only in CVS)

PDO::prepare --  Prepares a statement for execution and returns a statement object

Description

PDOStatement PDO::prepare ( string statement [, int options])

Warning

This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

Prepares an SQL statement to be executed by the statement-handle PDO::execute() method. The SQL statement can contain zero or more named (:name) or question mark (?) parameter markers.

Example 1. Prepare and execute an SQL statement

<?php
/* Execute a prepared statement by passing an array of values */
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < :calories AND colour = :colour'
);
$sth->execute(array(':calories' => 150, ':colour' => 'red'));
?>