[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] [doc-en] master: Improve mysqli_stmt_data_seek page (#2244)
From:       Kamil Tekiela via GitHub <noreply () php ! net>
Date:       2023-01-23 11:17:56
Message-ID: fpWHdfNj0ONfPXrRXC2fvc5ePkwyOPvCm466pzXKFA () main ! php ! net
[Download RAW message or body]

Author: Kamil Tekiela (kamil-tekiela)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2023-01-23T11:05:09Z

Commit: https://github.com/php/doc-en/commit/51c34024efa35d5691825b3e61037ffe61c46d20
Raw diff: https://github.com/php/doc-en/commit/51c34024efa35d5691825b3e61037ffe61c46d20.diff

Improve mysqli_stmt_data_seek page (#2244)

* Simplify code examples

* Add more See also

* Better description

Changed paths:
  M  reference/mysqli/mysqli_stmt/data-seek.xml


Diff:

diff --git a/reference/mysqli/mysqli_stmt/data-seek.xml b/reference/mysqli/mysqli_stmt/data-seek.xml
index 21121406275..65f7be1b633 100644
--- a/reference/mysqli/mysqli_stmt/data-seek.xml
+++ b/reference/mysqli/mysqli_stmt/data-seek.xml
@@ -4,7 +4,7 @@
  <refnamediv>
   <refname>mysqli_stmt::data_seek</refname>
   <refname>mysqli_stmt_data_seek</refname>
-  <refpurpose>Seeks to an arbitrary row in statement result set</refpurpose>
+  <refpurpose>Adjusts the result pointer to an arbitrary row in the buffered result</refpurpose>
  </refnamediv>
 
  <refsect1 role="description">
@@ -21,9 +21,11 @@
    <methodparam><type>int</type><parameter>offset</parameter></methodparam>
   </methodsynopsis>
   <para>
-   Seeks to an arbitrary result pointer in the statement result set.
+   This function moves the result set pointer of the buffered result set to
+   an arbitrary row specified by the <parameter>offset</parameter> parameter.
   </para>
   <para>
+   This function works only on the buffered internal result set.
    <function>mysqli_stmt_store_result</function> must be called prior to
    <function>mysqli_stmt_data_seek</function>.
   </para>
@@ -61,42 +63,24 @@
    <programlisting role="php">
 <![CDATA[
 <?php
-/* Open a connection */
-$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
 
-/* check connection */
-if (mysqli_connect_errno()) {
-    printf("Connect failed: %s\n", mysqli_connect_error());
-    exit();
-}
+mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
 
 $query = "SELECT Name, CountryCode FROM City ORDER BY Name";
-if ($stmt = $mysqli->prepare($query)) {
-
-    /* execute query */
-    $stmt->execute();
-
-    /* bind result variables */
-    $stmt->bind_result($name, $code);
-
-    /* store result */
-    $stmt->store_result();
+$stmt = $mysqli->prepare($query);
+$stmt->execute();
 
-    /* seek to row no. 400 */
-    $stmt->data_seek(399);
+$stmt->bind_result($name, $code);
 
-    /* fetch values */
-    $stmt->fetch();
+$stmt->store_result();
 
-    printf ("City: %s  Countrycode: %s\n", $name, $code);
+/* seek to row no. 400 */
+$stmt->data_seek(399);
 
-    /* close statement */
-    $stmt->close();
-}
+$stmt->fetch();
 
-/* close connection */
-$mysqli->close();
-?>
+printf("City: %s  Countrycode: %s\n", $name, $code);
 ]]>
    </programlisting>
   </example>
@@ -105,42 +89,25 @@ $mysqli->close();
    <programlisting role="php">
 <![CDATA[
 <?php
-/* Open a connection */
-$link = mysqli_connect("localhost", "my_user", "my_password", "world");
 
-/* check connection */
-if (mysqli_connect_errno()) {
-    printf("Connect failed: %s\n", mysqli_connect_error());
-    exit();
-}
+mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
 
 $query = "SELECT Name, CountryCode FROM City ORDER BY Name";
-if ($stmt = mysqli_prepare($link, $query)) {
-
-    /* execute query */
-    mysqli_stmt_execute($stmt);
-
-    /* bind result variables */
-    mysqli_stmt_bind_result($stmt, $name, $code);
+$stmt = mysqli_prepare($link, $query);
 
-    /* store result */
-    mysqli_stmt_store_result($stmt);
+mysqli_stmt_execute($stmt);
 
-    /* seek to row no. 400 */
-    mysqli_stmt_data_seek($stmt, 399);
+mysqli_stmt_bind_result($stmt, $name, $code);
 
-    /* fetch values */
-    mysqli_stmt_fetch($stmt);
+mysqli_stmt_store_result($stmt);
 
-    printf ("City: %s  Countrycode: %s\n", $name, $code);
+/* seek to row no. 400 */
+mysqli_stmt_data_seek($stmt, 399);
 
-    /* close statement */
-    mysqli_stmt_close($stmt);
-}
+mysqli_stmt_fetch($stmt);
 
-/* close connection */
-mysqli_close($link);
-?>
+printf("City: %s  Countrycode: %s\n", $name, $code);
 ]]>
    </programlisting>
    &examples.outputs;
@@ -157,6 +124,9 @@ City: Benin City  Countrycode: NGA
   <para>
    <simplelist>
     <member><function>mysqli_prepare</function></member>
+    <member><function>mysqli_stmt_store_result</function></member>
+    <member><function>mysqli_stmt_num_rows</function></member>
+    <member><function>mysqli_data_seek</function></member>
    </simplelist>
   </para>
  </refsect1>

-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic