EXPLAIN
TUDO!EXPLAIN SELECT * FROM 07_amazon_monitor_rank_results WHERE asin = '0672324547'
; 1 <?php
2 boolean mysqli_stmt_bind_param (mysqli_stmt stmt, string types, mixed &var1 [, mixed &varN)
3 class mysqli_stmt {
4 boolean bind_param (string types, mixed &var1 [, mixed &varN])
5 }
6
7 boolean mysqli_stmt_bind_result (mysqli_stmt stmt, mixed &var1 [, mixed &varN])
8
9 class mysqli_stmt {
10 boolean bind_result (mixed &var1 [, mixed &varN])
11 }
1 <?php
2 $link = mysqli_connect("localhost", "u", "p", "ex");
3 $city = "Montreal";
4 $stmt = mysqli_stmt_init($link);
5 if ($stmt = mysqli_stmt_prepare ($stmt, "SELECT Province FROM City WHERE Name=?"))
6 {
7 mysqli_stmt_bind_param($stmt, "s", $city);
8 mysqli_stmt_execute($stmt);
9 mysqli_stmt_bind_result($stmt, $province);
10 mysqli_stmt_fetch($stmt);
11 printf("%s is in district %s\n", $city, $province);
12 mysqli_stmt_close($stmt);
13 }
14 mysqli_close($link);
Permite juntar (merge) diversas consultas em uma operação atômica, ou TODAS executam com sucesso, ou nenhuma executara
1 BEGIN TRANSACTION #name;
2 ... queries here
3 COMMIT;
1 <?php
2 $pdoConnection = new PDO('mysql:host=localhost;dbname=example', USERNAME, PASSWORD);
3 foreach ($pdoConnection->query("SELECT * FROM users") AS $user) { echo $user['id']; }
Declarações Preparadas
1 <?php
2 $query = "SELECT * FROM posts WHERE topicID = :tid AND poster = :userid";
3 $statement = $pdoConnection->prepare($query, array(PDO::ATTR_CURSOR, PDO::CURSOR_FWDONLY));
4 $statement->execute(array(':tid' => 100, ':userid' => 12));
5 $userAPosts = $statement->fetchAll();
6 $statement->execute(array(':tid' => 100, ':userid' => 13));
7 $userBPosts = $statement->fetchAll();
fechando conexão
1 <?php
2 $pdoConnection = null; //
1 <?php
2 PDOStatement->nextRowset()
array PDO::errorInfo ( void )
* 0 - Código de erro SQLSTATE (um identificador de cinco caracteres alfanuméricos definido pelo padrão do ANSI SQL)
* 1 - Código de erro especifico indicado pelo driver.
* 2 - Mensagem especifica de erro indicada pelo driver.