cvs: peardoc /en/package/database/mdb2 intro-query.xml
| From: | Lukas Smith | Date: | Mon, 07 Aug 2006 11:11:49 +0000 |
| Subject: | cvs: peardoc /en/package/database/mdb2 intro-query.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-8253@lists.php.net to get a copy of this message | ||
lsmith Mon Aug 7 11:11:49 2006 UTC
Modified files:
/peardoc/en/package/database/mdb2 intro-query.xml
Log:
- added information about setLimit()
http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/mdb2/intro-query.xml?r1=1.8&r2=1.9&diff_format=u
Index: peardoc/en/package/database/mdb2/intro-query.xml
diff -u peardoc/en/package/database/mdb2/intro-query.xml:1.8
peardoc/en/package/database/mdb2/intro-query.xml:1.9
--- peardoc/en/package/database/mdb2/intro-query.xml:1.8 Fri Aug 4 23:20:39 2006
+++ peardoc/en/package/database/mdb2/intro-query.xml Mon Aug 7 11:11:49 2006
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<!--
+todos:
+
add information on the following methods:
-replace(), standaloneQuery(), subSelect() and setLimit()
+replace(), standaloneQuery(), subSelect()
-->
@@ -96,6 +98,45 @@
</para>
</refsect1>
+ <refsect1 id="package.database.mdb2.intro-query.setlimit">
+ <title>Limiting rows and reading from an offset</title>
+ <para>
+ In order to read/write to only a limited number of rows from a result set
+ and/or to start reading from a specific offset the
+ <ulink url="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2_Driver_Common.html#methodsetLimit">
+ <function>setLimit</function></ulink> can be called prior to issueing the
+ query. The limit and offset will only affected the next method call that
+ will issue a query or prepare a statement and will automatically be reset
+ after issueing the query. This also applies to any internal queries issues
+ inside MDB2. Note that limit may not work with DML statements on RDBMS that
+ emulate limit support and no error will be raised.
+ </para>
+
+ <example>
+ <title>Using exec to manipulate data</title>
+ <programlisting role="php">
+ <![CDATA[
+<?php
+// Once you have a valid MDB2 object named $mdb2...
+
+$sql = "SELECT * FROM clients";
+// read 20 rows with an offset of 10
+$mdb2->setLimit(20, 10);
+$affected =& $mdb2->exec($sql);
+
+$sql = "DELETE FROM clients";
+if ($mdb2->supported('limit_queries') === 'emulated') {
+ echo 'offset will likely be ignored'
+}
+// only delete 10 rows
+$mdb2->setLimit(10);
+$affected =& $mdb2->exec($sql);
+
+?>
+ ]]>
+ </programlisting>
+ </example>
+ </refsect1>
</refentry>
<!-- Keep this comment at the end of the file