mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
[PHP 8.1] Update mysqli_stmt::execute
description (#987)
Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
ab5887fb61
commit
9b50279c67
1 changed files with 90 additions and 2 deletions
|
@ -12,12 +12,13 @@
|
|||
<para>&style.oop;</para>
|
||||
<methodsynopsis role="oop">
|
||||
<modifier>public</modifier> <type>bool</type><methodname>mysqli_stmt::execute</methodname>
|
||||
<void/>
|
||||
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>params</parameter><initializer>&null;</initializer></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>&style.procedural;</para>
|
||||
<methodsynopsis role="procedural">
|
||||
<type>bool</type><methodname>mysqli_stmt_execute</methodname>
|
||||
<methodparam><type>mysqli_stmt</type><parameter>statement</parameter></methodparam>
|
||||
<methodparam choice="opt"><type class="union"><type>array</type><type>null</type></type><parameter>params</parameter><initializer>&null;</initializer></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Executes previously prepared statement. The statement must be successfully
|
||||
|
@ -42,6 +43,14 @@
|
|||
<para>
|
||||
<variablelist>
|
||||
&mysqli.stmt.description;
|
||||
<varlistentry>
|
||||
<term><parameter>params</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An optional list &array; with as many elements as there are bound parameters in the SQL statement being executed. Each value is treated as a &string;.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
@ -53,10 +62,32 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="changelog">
|
||||
&reftitle.changelog;
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>&Version;</entry>
|
||||
<entry>&Description;</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>8.1.0</entry>
|
||||
<entry>
|
||||
The optional <parameter>params</parameter> parameter has been added.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><methodname>mysqli_stmt::execute</methodname> example</title>
|
||||
<title>Execute a prepared statement with bound variables</title>
|
||||
<para>&style.oop;</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
|
@ -138,6 +169,63 @@ while ($row = mysqli_fetch_row($result)) {
|
|||
<![CDATA[
|
||||
Stuttgart (DEU,Baden-Wuerttemberg)
|
||||
Bordeaux (FRA,Aquitaine)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>Execute a prepared statement with an array of values</title>
|
||||
<para>&style.oop;</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'world');
|
||||
|
||||
$mysqli->query('CREATE TEMPORARY TABLE myCity LIKE City');
|
||||
|
||||
/* Prepare an insert statement */
|
||||
$stmt = $mysqli->prepare('INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)');
|
||||
|
||||
/* Execute the statement */
|
||||
$stmt->execute(['Stuttgart', 'DEU', 'Baden-Wuerttemberg']);
|
||||
|
||||
/* 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]);
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>&style.procedural;</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
$link = mysqli_connect('localhost', 'my_user', 'my_password', 'world');
|
||||
|
||||
mysqli_query($link, 'CREATE TEMPORARY TABLE myCity LIKE City');
|
||||
|
||||
/* Prepare an insert statement */
|
||||
$stmt = mysqli_prepare($link, 'INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)');
|
||||
|
||||
/* Execute the statement */
|
||||
mysqli_stmt_execute($stmt, ['Stuttgart', 'DEU', 'Baden-Wuerttemberg']);
|
||||
|
||||
/* 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]);
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
&examples.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Stuttgart (DEU,Baden-Wuerttemberg)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue