Parcourir la source

ZF-6517: Documentation: zend.db.table.fetch-all should demonstrate use of bind variables

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19139 44c647ce-9c0f-0410-b52a-842ac1e357ba
mikaelkael il y a 16 ans
Parent
commit
f14c082bd1
1 fichiers modifiés avec 21 ajouts et 2 suppressions
  1. 21 2
      documentation/manual/en/module_specs/Zend_Db_Table.xml

+ 21 - 2
documentation/manual/en/module_specs/Zend_Db_Table.xml

@@ -871,7 +871,9 @@ $rows = $table->find(array(1234, 5678), array('ABC', 'DEF'));
                     <para>
 
                         <programlisting language="php"><![CDATA[
-// Fetching a rowset
+/**
+ * Fetching a rowset
+ */
 $rows = $table->fetchAll(
     'bug_status = "NEW"',
     'bug_id ASC',
@@ -884,8 +886,18 @@ $rows = $table->fetchAll(
         ->order('bug_id ASC')
         ->limit(10, 0)
     );
+// or with binding
+$rows = $table->fetchAll(
+    $table->select()
+        ->where('bug_status = :status')
+        ->bind(array(':status'=>'NEW')
+        ->order('bug_id ASC')
+        ->limit(10, 0)
+    );
 
-// Fetching a single row
+/**
+ * Fetching a single row
+ */
 $row = $table->fetchRow(
     'bug_status = "NEW"',
     'bug_id ASC'
@@ -895,6 +907,13 @@ $row = $table->fetchRow(
         ->where('bug_status = ?', 'NEW')
         ->order('bug_id ASC')
     );
+// or with binding
+$row = $table->fetchRow(
+    $table->select()
+        ->where('bug_status = :status')
+        ->bind(array(':status'=>'NEW')
+        ->order('bug_id ASC')
+    );
 ]]></programlisting>
 
                     </para>