|
@@ -786,7 +786,7 @@ echo $result[0]->bug_description;
|
|
|
<para>
|
|
<para>
|
|
|
The <methodname>fetchAssoc()</methodname> method returns data in an array
|
|
The <methodname>fetchAssoc()</methodname> method returns data in an array
|
|
|
of associative arrays, regardless of what value you have set
|
|
of associative arrays, regardless of what value you have set
|
|
|
- for the fetch mode.
|
|
|
|
|
|
|
+ for the fetch mode, using the first column as the array index.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<example id="zend.db.adapter.select.fetchassoc.example">
|
|
<example id="zend.db.adapter.select.fetchassoc.example">
|
|
@@ -795,10 +795,11 @@ echo $result[0]->bug_description;
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
|
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$db->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
|
|
|
|
|
|
-$result = $db->fetchAssoc('SELECT * FROM bugs WHERE bug_id = ?', 2);
|
|
|
|
|
|
|
+$result = $db->fetchAssoc('SELECT bug_id, bug_description, bug_status FROM bugs');
|
|
|
|
|
|
|
|
// $result is an array of associative arrays, in spite of the fetch mode
|
|
// $result is an array of associative arrays, in spite of the fetch mode
|
|
|
-echo $result[0]['bug_description'];
|
|
|
|
|
|
|
+echo $result[2]['bug_description']; // Description of Bug #2
|
|
|
|
|
+echo $result[1]['bug_description']; // Description of Bug #1
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
</sect3>
|
|
</sect3>
|