cvs: peardoc /en/package/database/db-table intro-table.xml
| From: | David Morse | Date: | Thu, 28 Jun 2007 22:35:24 +0000 |
| Subject: | cvs: peardoc /en/package/database/db-table intro-table.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-9842@lists.php.net to get a copy of this message | ||
morse Thu Jun 28 22:35:24 2007 UTC
Modified files:
/peardoc/en/package/database/db-table intro-table.xml
Log:
Noted that:
i) Select*() methods can accept query array arguments
ii) Existence of base class DB_Table_Base
http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/db-table/intro-table.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/database/db-table/intro-table.xml diff -u peardoc/en/package/database/db-table/intro-table.xml:1.2 peardoc/en/package/database/db-table/intro-table.xml:1.3 --- peardoc/en/package/database/db-table/intro-table.xml:1.2 Sat Jun 2 18:04:02 2007 +++ peardoc/en/package/database/db-table/intro-table.xml Thu Jun 28 22:35:24 2007 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.database.db-table.intro-table"> <refnamediv> @@ -70,6 +70,17 @@ that are not included here. </para> +<para> +The <classname>DB_Table</classname> and +<classname>DB_Table_Database</classname> classes both extend an abstract +base class named <classname>DB_Table_Base</classname>. Methods and +properties that are inherited from <classname>DB_Table_Base</classname> +are thus available via either a <classname>DB_Table</classname> or a +<classname>DB_Table_Database</classname> object, with the same interface. +These shared methods and properties will be identified as such in these +manual pages. +</para> + <itemizedlist> <title>Contents</title> <listitem> @@ -113,25 +124,25 @@ <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.insert"> - <function>insert</function></link> - Inserting rows of data + <function>insert</function> - Inserting rows of data </link> </simpara> </listitem> <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.autoinc"> - Auto-increment columns and sequences</link> + Auto-increment and sequences</link> </simpara> </listitem> <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.update"> - <function>update</function></link> - Updating rows of data + <function>update</function> - Updating rows of data</link> </simpara> </listitem> <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.delete"> - <function>insert</function></link> - Deleting rows of data + <function>delete</function> - Deleting rows of data</link> </simpara> </listitem> </itemizedlist> @@ -150,6 +161,12 @@ </listitem> <listitem> <simpara> + <link linkend="package.database.db-table.intro-table.select.stored"> + Storing Queries: $this->sql</link> + </simpara> + </listitem> + <listitem> + <simpara> <link linkend="package.database.db-table.intro-table.select.submit"> Submitting Queries: <function>select*</function> methods</link> </simpara> @@ -833,19 +850,20 @@ (e.g., SELECT, FROM, WHERE clauses) is stored in a different element. This representation makes it relatively easy to modify a query by, <emphasis>e.g.</emphasis>, adding additional conditions to the WHERE -clause to further limit the returned set of rows. -Commonly used queries, and "baseline" queries that are useful as the -basis of more complicated queries, may be stored in the $sql public -property array. The $sql property is a associative array in which keys -are query names, and values are query arrays. +clause to further limit the returned set of rows. Query arrays may be +stored in the $sql property array. </para> <para> Queries may be submitted to the database using either the -<function>select</function> method, which generally returns the results as -an array, or the <function>selectResult</function> method, which returns a -<classname>DB_Result</classname> or <classname>MDB2_Result_Common</classname> -return set object. +<function>select</function> method, which generally returns the +result set as an array, or the <function>selectResult</function> +method, which returns a <classname>DB_Result</classname> or +<classname>MDB2_Result_Common</classname> result set object. +These three methods are all inherited from the +<classname>DB_Table_Base</classname> base class, and thus are also +available as methods of a <classname>DB_Table_Database</classname> +object. </para> <refsect2 id="package.database.db-table.intro-table.select.queryarray"> @@ -1014,6 +1032,38 @@ restored before the <function>select</function> method returns. </para> +</refsect2> + +<refsect2 id="package.database.db-table.intro-table.select.stored"> +<title>Storing Queries: $sql property array</title> +<para> +Commonly used queries, and "baseline" queries that are useful as +a starting point for construction of more complicated ones, may be +stored in the $sql public property array. The $sql property is an +associative array in which keys are query names, and values are +query arrays. Stored queries can be submitted by passing the name +key for the query as an argument to any of the +<classname>select*()</classname> methods. +</para> + +<para> +The $sql property is inherited from the +<classname>DB_Table_Base</classname> class. Queries may thus be +stored either the $sql property of a <classname>DB_Table</classname> +that provides an interface to a specific table, or in the $sql property +of a <classname>DB_Table_Database</classname> object that provides an +interface to the entire database. For applications that involve only +one table, or queries that involve only one table, it may be +convenient to use the $sql property of the +<classname>DB_Table</classname> object, as in the above example, and +to then use the <function>select*</function> methods of that object +to access these queries by name. For more complicated queries and +applications, however, it may be more convenient to store all queries +in the $sql property of a <classname>DB_Table_Database</classname> +object, and submit them by name via the <function>select*</function> +methods of that object. +</para> + <example> <title>Defining Baseline Queries in a <classname>DB_Table</classname> Subclass Definition</title> @@ -1090,25 +1140,25 @@ The <function>select</function> method submits a query and returns the result set as an array. The <function>selectResult</function> method returns the result as a <classname>DB_Result/MDB2_Result_Common</classname> -object. The <function>selectCount</function> method returns an integer +object. The <function>selectCount</function> method returns an integer equal to the number of rows that would be returned by a query, without returning the actual result set. </para> <para> -The interface is the same for all three of these methods. In each, -the first parameter, which is required, is the name of a stored query -definition, which is an array key in the $sql property array. The -remaining parameters, which are all optional, may be used to modify the -submitted query without modifying the stored query array. The second -parameter, $filter, is a string that contains an SQL logical expression -that will be ANDed with the WHERE clause of the query before the SELECT -statement is constructed and submitted, without modifying the stored -query. The third parameter, $order, if present, is used as a replacement -for the value of the 'order' element of the query array. The fourth and - fifth parameters, $start and $count, are integers that specify the first - row of the result set that should be returned, and the maximum number - of rows to be returned. +The interface is the same for all three of these methods. In each, the +first parameter, which is required, can be either a query array or a +key of the $sql property array, for which the corresponding value is a +stored query array. The remaining parameters, which are all optional, +may be used to modify the query before submission to the database. The +second parameter, $filter, is a string that contains an SQL logical +expression that will be ANDed with the WHERE clause of the query before +the SELECT command is submitted. The third parameter, $order, if present, +is used to construct the 'ORDER BY' clause, and may be used to override +the 'order' element of the query. The fourth and fifth parameters, $start +and $count, are integers that may be used to specify the first row of the +result set that should be returned, and the maximum number of rows to be +returned. </para> <example>
http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/db-table/intro-table.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/database/db-table/intro-table.xml diff -u peardoc/en/package/database/db-table/intro-table.xml:1.2 peardoc/en/package/database/db-table/intro-table.xml:1.3 --- peardoc/en/package/database/db-table/intro-table.xml:1.2 Sat Jun 2 18:04:02 2007 +++ peardoc/en/package/database/db-table/intro-table.xml Thu Jun 28 22:35:24 2007 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.database.db-table.intro-table"> <refnamediv> @@ -70,6 +70,17 @@ that are not included here. </para> +<para> +The <classname>DB_Table</classname> and +<classname>DB_Table_Database</classname> classes both extend an abstract +base class named <classname>DB_Table_Base</classname>. Methods and +properties that are inherited from <classname>DB_Table_Base</classname> +are thus available via either a <classname>DB_Table</classname> or a +<classname>DB_Table_Database</classname> object, with the same interface. +These shared methods and properties will be identified as such in these +manual pages. +</para> + <itemizedlist> <title>Contents</title> <listitem> @@ -113,25 +124,25 @@ <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.insert"> - <function>insert</function></link> - Inserting rows of data + <function>insert</function> - Inserting rows of data </link> </simpara> </listitem> <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.autoinc"> - Auto-increment columns and sequences</link> + Auto-increment and sequences</link> </simpara> </listitem> <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.update"> - <function>update</function></link> - Updating rows of data + <function>update</function> - Updating rows of data</link> </simpara> </listitem> <listitem> <simpara> <link linkend="package.database.db-table.intro-table.modify.delete"> - <function>insert</function></link> - Deleting rows of data + <function>delete</function> - Deleting rows of data</link> </simpara> </listitem> </itemizedlist> @@ -150,6 +161,12 @@ </listitem> <listitem> <simpara> + <link linkend="package.database.db-table.intro-table.select.stored"> + Storing Queries: $this->sql</link> + </simpara> + </listitem> + <listitem> + <simpara> <link linkend="package.database.db-table.intro-table.select.submit"> Submitting Queries: <function>select*</function> methods</link> </simpara> @@ -833,19 +850,20 @@ (e.g., SELECT, FROM, WHERE clauses) is stored in a different element. This representation makes it relatively easy to modify a query by, <emphasis>e.g.</emphasis>, adding additional conditions to the WHERE -clause to further limit the returned set of rows. -Commonly used queries, and "baseline" queries that are useful as the -basis of more complicated queries, may be stored in the $sql public -property array. The $sql property is a associative array in which keys -are query names, and values are query arrays. +clause to further limit the returned set of rows. Query arrays may be +stored in the $sql property array. </para> <para> Queries may be submitted to the database using either the -<function>select</function> method, which generally returns the results as -an array, or the <function>selectResult</function> method, which returns a -<classname>DB_Result</classname> or <classname>MDB2_Result_Common</classname> -return set object. +<function>select</function> method, which generally returns the +result set as an array, or the <function>selectResult</function> +method, which returns a <classname>DB_Result</classname> or +<classname>MDB2_Result_Common</classname> result set object. +These three methods are all inherited from the +<classname>DB_Table_Base</classname> base class, and thus are also +available as methods of a <classname>DB_Table_Database</classname> +object. </para> <refsect2 id="package.database.db-table.intro-table.select.queryarray"> @@ -1014,6 +1032,38 @@ restored before the <function>select</function> method returns. </para> +</refsect2> + +<refsect2 id="package.database.db-table.intro-table.select.stored"> +<title>Storing Queries: $sql property array</title> +<para> +Commonly used queries, and "baseline" queries that are useful as +a starting point for construction of more complicated ones, may be +stored in the $sql public property array. The $sql property is an +associative array in which keys are query names, and values are +query arrays. Stored queries can be submitted by passing the name +key for the query as an argument to any of the +<classname>select*()</classname> methods. +</para> + +<para> +The $sql property is inherited from the +<classname>DB_Table_Base</classname> class. Queries may thus be +stored either the $sql property of a <classname>DB_Table</classname> +that provides an interface to a specific table, or in the $sql property +of a <classname>DB_Table_Database</classname> object that provides an +interface to the entire database. For applications that involve only +one table, or queries that involve only one table, it may be +convenient to use the $sql property of the +<classname>DB_Table</classname> object, as in the above example, and +to then use the <function>select*</function> methods of that object +to access these queries by name. For more complicated queries and +applications, however, it may be more convenient to store all queries +in the $sql property of a <classname>DB_Table_Database</classname> +object, and submit them by name via the <function>select*</function> +methods of that object. +</para> + <example> <title>Defining Baseline Queries in a <classname>DB_Table</classname> Subclass Definition</title> @@ -1090,25 +1140,25 @@ The <function>select</function> method submits a query and returns the result set as an array. The <function>selectResult</function> method returns the result as a <classname>DB_Result/MDB2_Result_Common</classname> -object. The <function>selectCount</function> method returns an integer +object. The <function>selectCount</function> method returns an integer equal to the number of rows that would be returned by a query, without returning the actual result set. </para> <para> -The interface is the same for all three of these methods. In each, -the first parameter, which is required, is the name of a stored query -definition, which is an array key in the $sql property array. The -remaining parameters, which are all optional, may be used to modify the -submitted query without modifying the stored query array. The second -parameter, $filter, is a string that contains an SQL logical expression -that will be ANDed with the WHERE clause of the query before the SELECT -statement is constructed and submitted, without modifying the stored -query. The third parameter, $order, if present, is used as a replacement -for the value of the 'order' element of the query array. The fourth and - fifth parameters, $start and $count, are integers that specify the first - row of the result set that should be returned, and the maximum number - of rows to be returned. +The interface is the same for all three of these methods. In each, the +first parameter, which is required, can be either a query array or a +key of the $sql property array, for which the corresponding value is a +stored query array. The remaining parameters, which are all optional, +may be used to modify the query before submission to the database. The +second parameter, $filter, is a string that contains an SQL logical +expression that will be ANDed with the WHERE clause of the query before +the SELECT command is submitted. The third parameter, $order, if present, +is used to construct the 'ORDER BY' clause, and may be used to override +the 'order' element of the query. The fourth and fifth parameters, $start +and $count, are integers that may be used to specify the first row of the +result set that should be returned, and the maximum number of rows to be +returned. </para> <example>