<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2009/10/bug-in-phplibmtdb-basephp-line-229---list-causes-only-first-result-in-a-array-to-be-returned.html" />
  <link rel="self" type="application/atom+xml" href="http://forums.movabletype.org/atom.xml" />
  <id>tag:forums.movabletype.org,2011://24/tag:forums.movabletype.org,2009://24.17758-</id>
  <updated>2011-09-01T02:22:11Z</updated>
  <title>Comments for Bug in php/lib/mtdb_base.php line 229 - list() causes only first result in a array to be returned</title>
  
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.292</generator>
  <entry>
    <id>tag:forums.movabletype.org,2009://24.17758</id>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2009/10/bug-in-phplibmtdb-basephp-line-229---list-causes-only-first-result-in-a-array-to-be-returned.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://www.movabletype.org/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=24/entry_id=17758" title="Bug in php/lib/mtdb_base.php line 229 - list() causes only first result in a array to be returned" />
    <published>2009-10-13T21:05:16Z</published>
    <updated>2009-10-15T10:36:36Z</updated>
    <title>Bug in php/lib/mtdb_base.php line 229 - list() causes only first result in a array to be returned</title>
    <summary>227 function fetch_config() { 228 $sql = &quot;select * from mt_config&quot;; 229 list($row) = $this-&gt;get_results($sql, ARRAY_A); 230 if (!$row) return null; 231 return $row; 232 } the use of list here is problematic if the desire is to return multiple...</summary>
    <author>
      <name>Tekimaki</name>
      
    </author>
    
    <category term="Open Source" />
    
    <content type="html" xml:lang="en" xml:base="http://forums.movabletype.org/">
      <![CDATA[<p>227     function fetch_config() {<br />
 228         $sql = "select * from mt_config";<br />
 229         list($row) = $this->get_results($sql, ARRAY_A);<br />
 230         if (!$row) return null;<br />
 231         return $row;<br />
 232     }</p>

<p>the use of list here is problematic if the desire is to return multiple rows of config values from the mt_config table. In a multirow result list() will only grab the results in the first array it encounters.</p>

<p>its not clear to me the design of mt_config because MT is stuffing all config values into one row (seems to defeat the point of using a table). since its a table I would assume mutliple rows is the intent (no matter what the MT kernel is doing with the base config values), and thus this function seems broken. </p>

<p>the fix is obvious, iterate over the returned hash and merge the results (pretty nasty results, but its what the caller would expect at least).</p>

<p>Though I have not installed any of the 5beta branches it seems like those will have a similar problem as the code still doesnt look for multiple rows returned - tho that code doesnt seem to make sense to me at all since I dont see where Load learns to select from mt_config, the table is not passed in a class.mt_config.php Load function, which is what I would have expected looking at that code.</p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:forums.movabletype.org,2009://24.17758-comment:31384</id>
    <thr:in-reply-to ref="tag:forums.movabletype.org,2009://24.17758" type="text/html" href="http://forums.movabletype.org/2009/10/bug-in-phplibmtdb-basephp-line-229---list-causes-only-first-result-in-a-array-to-be-returned.html"/>
    <link rel="alternate" type="text/html" href="http://forums.movabletype.org/2009/10/bug-in-phplibmtdb-basephp-line-229---list-causes-only-first-result-in-a-array-to-be-returned.html#c31384" />
    <title>Comment from Mike T on 2009-10-15</title>
    <author>
        <name>Mike T</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>File a bug report @ <a href="http://www.movabletype.org/feedback.html">http://www.movabletype.org/feedback.html</a></p>]]>
    </content>
    <published>2009-10-15T10:36:36Z</published>
  </entry>

</feed>

