显示下拉菜单

PDOStatement::execute()

« PDOStatement::errorInfo | PDOStatement::fetch »
<?php
$pdo 
= new PDO("sqlite::memory:"nullnull, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$int $pdo->exec(
    
  // string $exec_statement
);

$pdostatement $pdo->prepare(
    
// string $statement,
    
 // array $driver_options = array()
);

$bool $pdostatement->execute (
    
  // [array $input_parameters]
);
?>
结果
$pdo = 'PDO instance'
$int = 7
$pdostatement = 'PDOStatement instance'
$bool = true
示例
#1 PDOStatement::execute  (/* $exec_statement = "CREATE TABLE fruit (name, colour, calories INT); INSERT INTO fruit VALUES ('apple', 'red', 150), ('banana', 'yellow', 250), ('kiwi', 'brown', 75), ('lemon', 'yellow', 25), ('orange', 'orange', 300), ('pear', 'green', 150), ('watermelon', 'pink', 90)" */
 /* $statement = "SELECT name, colour, calories FROM fruit" */
)
#2 PDOStatement::execute  (/* $exec_statement = "CREATE TABLE fruit (name, colour, calories INT); INSERT INTO fruit VALUES ('apple', 'red', 150), ('banana', 'yellow', 250), ('kiwi', 'brown', 75), ('lemon', 'yellow', 25), ('orange', 'orange', 300), ('pear', 'green', 150), ('watermelon', 'pink', 90)" */
 /* $statement = "SELECT name, colour, calories FROM fruit WHERE calories <= :calories AND colour = :colour" */
 
[":calories" => 150":colour" => "red"])
#3 PDOStatement::execute  (/* $exec_statement = "CREATE TABLE fruit (name, colour, calories INT); INSERT INTO fruit VALUES ('apple', 'red', 150), ('banana', 'yellow', 250), ('kiwi', 'brown', 75), ('lemon', 'yellow', 25), ('orange', 'orange', 300), ('pear', 'green', 150), ('watermelon', 'pink', 90)" */
 /* $statement = "SELECT name, colour, calories FROM fruit WHERE calories <= ? AND colour = ?" */
 
[=> 150=> "red"])
另请参阅
PDO::exec, PDO::prepare, PDOStatement::fetch, PDOStatement::fetchAll, PDOStatement::fetchColumn