mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Small fixes in pdo execute (#989)
* Use temporary table instead * Uppercase * Better description
This commit is contained in:
parent
b0b19b6618
commit
ab5887fb61
1 changed files with 8 additions and 12 deletions
|
@ -30,8 +30,10 @@
|
|||
If the statement is <literal>UPDATE</literal>, <literal>DELETE</literal>,
|
||||
or <literal>INSERT</literal>, the total number of affected rows can be
|
||||
determined by using the <function>mysqli_stmt_affected_rows</function>
|
||||
function. Likewise, if the query yields a result set the
|
||||
<function>mysqli_stmt_fetch</function> function is used.
|
||||
function. If the query yields a result set, it can be fetched using
|
||||
<function>mysqli_stmt_get_result</function> function or by fetching it
|
||||
row by row directly from the statement using
|
||||
<function>mysqli_stmt_fetch</function> function.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
@ -63,7 +65,7 @@
|
|||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
|
||||
|
||||
$mysqli->query("CREATE TABLE myCity LIKE City");
|
||||
$mysqli->query("CREATE TEMPORARY TABLE myCity LIKE City");
|
||||
|
||||
/* Prepare an insert statement */
|
||||
$stmt = $mysqli->prepare("INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)");
|
||||
|
@ -85,15 +87,12 @@ $val3 = 'Aquitaine';
|
|||
/* Execute the statement */
|
||||
$stmt->execute();
|
||||
|
||||
/* retrieve all rows from myCity */
|
||||
/* Retrieve all rows from myCity */
|
||||
$query = "SELECT Name, CountryCode, District FROM myCity";
|
||||
$result = $mysqli->query($query);
|
||||
while ($row = $result->fetch_row()) {
|
||||
printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
|
||||
}
|
||||
|
||||
/* remove table */
|
||||
$mysqli->query("DROP TABLE myCity");
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>&style.procedural;</para>
|
||||
|
@ -104,7 +103,7 @@ $mysqli->query("DROP TABLE myCity");
|
|||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
|
||||
|
||||
mysqli_query($link, "CREATE TABLE myCity LIKE City");
|
||||
mysqli_query($link, "CREATE TEMPORARY TABLE myCity LIKE City");
|
||||
|
||||
/* Prepare an insert statement */
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)");
|
||||
|
@ -126,15 +125,12 @@ $val3 = 'Aquitaine';
|
|||
/* Execute the statement */
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
/* retrieve all rows from myCity */
|
||||
/* Retrieve all rows from myCity */
|
||||
$query = "SELECT Name, CountryCode, District FROM myCity";
|
||||
$result = mysqli_query($link, $query);
|
||||
while ($row = mysqli_fetch_row($result)) {
|
||||
printf("%s (%s,%s)\n", $row[0], $row[1], $row[2]);
|
||||
}
|
||||
|
||||
/* remove table */
|
||||
mysqli_query($link, "DROP TABLE myCity");
|
||||
]]>
|
||||
</programlisting>
|
||||
&examples.outputs;
|
||||
|
|
Loading…
Reference in a new issue