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])

Atenção

Esta função é EXPERIMENTAL. Isso quer dizer que o comportamento desta função e seu nome, incluindo TUDO o que está documentado aqui pode mudar em futuras versões do PHP, SEM QUALQUER NOTIFICAÇÃO. Esteja avisado, e use esta função por sua própria conta e risco.

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.

Exemplo 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'));
?>