cvs: peardoc /en/core db.xml

From: Date: Sat, 29 Dec 2001 10:29:36 +0000
Subject: cvs: peardoc /en/core db.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1755@lists.php.net to get a copy of this message
mj Sat Dec 29 05:29:36 2001 EDT Modified files: /peardoc/en/core db.xml Log: * Typos etc.

Index: peardoc/en/core/db.xml diff -u peardoc/en/core/db.xml:1.8 peardoc/en/core/db.xml:1.9 --- peardoc/en/core/db.xml:1.8 Tue Dec 25 15:39:47 2001 +++ peardoc/en/core/db.xml Sat Dec 29 05:29:36 2001 @@ -1,5 +1,5 @@ <?xml encoding="iso-8859-1"?> -<!-- $Revision: 1.8 $ --> +<!-- $Revision: 1.9 $ --> <reference id="core.db"> <title>PEAR DB: a unified API for accessing SQL-databases</title> @@ -114,7 +114,7 @@ <simpara> To connect to a database you have to use the function <function>DB::connect</function>, which requires a valid - <link linkend="packages.db.dsn">DSN</link> as parameter and + <link linkend="core.db.dsn">DSN</link> as parameter and optional a boolean value, which determines wether to use a persistent connection or not. In case of success you get a new instance of the database class. It is strongly recommened to @@ -464,9 +464,10 @@ $all_client_names = array('Stig', 'Jon', 'Colin'); </para> <para> - <function>getAssoc</function> Fetch the entire result set of a query and return it as an - associative array using the first column as the key. - <programlisting role="php"> + <function>getAssoc</function> fetches the entire result set + of a query and return it as an associative array using the + first column as the key. + <programlisting role="php"> <![CDATA[ $data = getAssoc('SELECT name, surname, phone FROM mytable') /* @@ -481,9 +482,10 @@ </programlisting> </para> <para> - <function>getAll</function> Fetch all the rows returned from a query + <function>getAll</function> fetches all the rows returned from + a query <programlisting role="php"> - <![CDATA[ + <![CDATA[ $data = getAll('SELECT id, text, date FROM mytable'); /* Will return: @@ -505,10 +507,10 @@ </para> </refsect2> <refsect2> - <title>Getting more info from query results</title> + <title>Getting more information from query results</title> <para> - With Pear DB you have many ways to retrieve useful information + With PEAR DB you have many ways to retrieve useful information from query results. These are: <itemizedlist> <listitem> @@ -544,7 +546,7 @@ <![CDATA[ // remember that this statement won't return a result object $db->query('DELETE * FROM clients'); -echo 'I have deleted ' . $db->affectedRows() . 'clients'; +echo 'I have deleted ' . $db->affectedRows() . ' clients'; ]]> </programlisting> </para> @@ -557,7 +559,7 @@ <programlisting role="php"> <![CDATA[ // Table Info -print_r ($res->tableInfo()); +print_r($res->tableInfo()); ]]> </programlisting> </para> @@ -565,8 +567,8 @@ </itemizedlist> Don't forget to check if the returned result from your action is a PEAR Error object. If you get a error message like - <quote>DB_error: database not capable</quote>, means that your - database backend doesn't support this action. + <quote>DB_error: database not capable</quote>, that means that + your database backend doesn't support this action. </para> </refsect2> </refsect1> @@ -580,7 +582,7 @@ <refsect1> <title>Description</title> <para> - Sequences is a way of offering unique IDs for data rows. If you + Sequences are a way of offering unique IDs for data rows. If you do most of you work with e.g. MySQL, think of sequences as another way of doing AUTO_INCREMENT. It's quite simple, first you request an ID, and then you insert that value in the ID field of @@ -593,7 +595,7 @@ <![CDATA[ <?php ... -$id = $db->nextID('mySequence'); +$id = $db->nextId('mySequence'); // Use the ID in your INSERT query $res = $db->query("INSERT INTO myTable (id,text) VALUES ($id,'foo')"); ... @@ -615,14 +617,14 @@ <title>Purpose</title> <para> <function>Prepare</function> and <function>execute*</function> - gives you more power and flexibilty for query execution. You - can use them, if you have to do more then one equal queries + give you more power and flexibilty for query execution. You + can use them, if you have to do more than one equal query (i.e. adding a list of adresses to a database) or if you want to support different databases, which have different implementations of the SQL standard. </para> <para> - Maybe you want to support two databases with different INSERT + Imagine you want to support two databases with different INSERT syntax: <programlisting role="php"> <![CDATA[ @@ -645,31 +647,31 @@ <title>Prepare</title> <para> To use the features give - in <link linkend="packages.db.prep_exec.purpose">Purpose</link> - you have to to two steps. Step one is to + in <link linkend="core.db.prep_exec.purpose">Purpose</link> + you have to do two steps. Step one is to <emphasis>prepare</emphasis> the statment and the second is to <emphasis>excute</emphasis> it. </para> <para> - <function>Prepare</function> have to called with the generic + <function>Prepare</function> has to be called with the generic statment at least once. It returns a handle for the statment. </para> <para> To create a generic statment is simple. Write the SQL query as usual, i.e. - <programlisting role="php"> + <programlisting> <![CDATA[ SELECT surname, name, age FROM person WHERE name = 'name_to_find' AND age < 'age_limit' ]]> </programlisting> Now check which parameters should be replaced while script runtime. Substitute this parameters with a placeholder. - <programlisting role="php"> + <programlisting> <![CDATA[ SELECT surname, name, age FROM person WHERE name = ? AND age < ? ]]> </programlisting> - So, thats all! Now you have a generic statment, required by + So, thats all! Now you have a generic statement, required by <function>prepare</function>. </para> <para> @@ -695,18 +697,18 @@ <refsect2> <title>Execute/ ExecuteMultiple</title> <para> - After preparing the statment, you can excute the query. This - means to assign the variables to the prepared statment. To do - this, <function>execute</function> requires to arguments, the - statment handle of <function>prepare</function> and a array - with the values to assign. The array has to be numeric ordered. - The first entry of the array represents the first wildcard, - the second the second etc. The order is independent from the - used wildcard char. + After preparing the statement, you can excute the query. This + means to assign the variables to the prepared statement. To do + this, <function>execute</function> requires two arguments, the + statement handle of <function>prepare</function> and an array + with the values to assign. The array has to be numerically + ordered. The first entry of the array represents the first + wildcard, the second the second wildcard etc. The order is + independent from the used wildcard char. <programlisting role="php"> <![CDATA[ <?php -//// Example inserting data +// Example inserting data $alldata = array( array(1, 'one', 'en'), array(2, 'two', 'to'), array(3, 'three', 'tre'), @@ -719,7 +721,7 @@ ]]> </programlisting> In the example the query is done four times: - <programlisting role="php"> + <programlisting> <![CDATA[ INSERT INTO numbers VALUES( '1', 'one', 'en') INSERT INTO numbers VALUES( '2', 'two', 'to') @@ -733,7 +735,7 @@ <programlisting role="php"> <![CDATA[ <?php -//// Example inserting data +// Example inserting data $alldata = array( array(1, 'one', 'en'), array(2, 'two', 'to'), array(3, 'three', 'tre'),
« previous php.pear.cvs (#1755) next »