cvs: peardoc /en/package/database/db intro-query.xml

From: Date: Mon, 26 Jan 2004 20:24:59 +0000
Subject: cvs: peardoc /en/package/database/db intro-query.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2168@lists.php.net to get a copy of this message
danielc Mon Jan 26 15:24:59 2004 EDT Modified files: /peardoc/en/package/database/db intro-query.xml Log: Explain prepare/execute mode. http://cvs.php.net/diff.php/peardoc/en/package/database/db/intro-query.xml?r1=1.5&r2=1.6&ty=u Index: peardoc/en/package/database/db/intro-query.xml diff -u peardoc/en/package/database/db/intro-query.xml:1.5 peardoc/en/package/database/db/intro-query.xml:1.6 --- peardoc/en/package/database/db/intro-query.xml:1.5 Thu Jun 5 01:54:27 2003 +++ peardoc/en/package/database/db/intro-query.xml Mon Jan 26 15:24:59 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <refentry id="package.database.db.intro-query"> <refnamediv> <refname>Introduction - Query</refname> @@ -39,6 +39,55 @@ ]]> </programlisting> </example> + <para> + <function>query</function> can be used instead of + <link linkend="package.database.db.db-common.prepare"> + <function>prepare</function></link> and + <link linkend="package.database.db.db-common.execute"> + <function>execute</function></link>, if you + set the <parameter>$params</parameter> parameter + and your query uses placeholders. + </para> + <example> + <title>Using query in prepare/execute mode with a scalar parameter</title> + <programlisting role="php"> + <![CDATA[ +<?php +// Once you have a valid DB object... +$sql = 'select * from clients where clientid = ? and statusid = ?'; +$data = 53; + +$result = $db->query($sql, $data); + +// Always check that $result is not an error +if (DB::isError($result)) { + die ($result->getMessage()); +} +.... +?> +]]> + </programlisting> + </example> + <example> + <title>Using query in prepare/execute mode with an array parameter</title> + <programlisting role="php"> + <![CDATA[ +<?php +// Once you have a valid DB object... +$sql = 'select * from clients where clientid = ?'; +$data = array(53, 4); + +$result = $db->query($sql, $data); + +// Always check that $result is not an error +if (DB::isError($result)) { + die ($result->getMessage()); +} +.... +?> +]]> + </programlisting> + </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file

« previous php.pear.doc (#2168) next »