PDOStatement::execute

(no version information, might be only in CVS)

PDOStatement::execute --  Executes a prepared statement

Description

bool PDOStatement::execute ( [array input_parameters] )

Warnung

Diese Funktion ist EXPERIMENTELL. Das Verhalten, der Funktionsname und alles Andere was hier dokumentiert ist, kann sich in zukünftigen PHP-Versionen ohne Ankündigung ändern. Seien Sie gewarnt und verwenden Sie diese Funktion auf eigenes Risiko.

Execute the prepared statement. If the prepared statement included parameter markers, you must either:

Beispiel 1. Execute a prepared statement with bound variables

<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < :calories AND colour = :colour'
);
$sth->bindParam(':calories', $calories, PDO_PARAM_INT);
$sth->bindParam(':colour', $colour, PDO_PARAM_STR, 12);
$sth->execute();
?>

Beispiel 2. Execute a prepared statement with an array of insert values

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

Beispiel 3. Execute a prepared statement with question mark placeholders

<?php
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < ? AND colour = ?'
);
$sth->bindParam(1, $calories, PDO_PARAM_INT);
$sth->bindParam(2, $colour, PDO_PARAM_STR, 12);
$sth->execute();
?>

Hosting by: Hurra Communications GmbH
Generated: 2007-01-26 17:57:07