<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Documentation</title>
	<atom:link href="http://lukebaker.org/projects/activerecord-in-php/documentation/feed/" rel="self" type="application/rss+xml" />
	<link>http://lukebaker.org</link>
	<description>lukebaker.org</description>
	<lastBuildDate>Thu, 15 Sep 2011 16:37:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Matt Borja</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-31792</link>
		<dc:creator>Matt Borja</dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-31792</guid>
		<description>Update (replace previous comment):

If you don&#039;t explicitly check the types while making comparisons, you&#039;ll find that

int(0) == (string)&#039;all&#039; OR (string)&#039;first&#039;

This is why passing 0 doesn&#039;t work or will yield ALL results. Find these lines in ActiveRecord.php (around 362-367) and add the === comparison operator (!== for bool NOT):

      if (is_array($id))
        $where = &quot;{$item-&gt;primary_key} IN (&quot; . implode(&quot;,&quot;, $id) . &quot;)&quot;;
      elseif ($id === &#039;first&#039;) 
        $limit = &#039;1&#039;;
      elseif ($id !== &#039;all&#039;)
        $where = &quot;{$item-&gt;table_name}.{$item-&gt;primary_key} = $id&quot;;</description>
		<content:encoded><![CDATA[<p>Update (replace previous comment):</p>
<p>If you don&#8217;t explicitly check the types while making comparisons, you&#8217;ll find that</p>
<p>int(0) == (string)&#8217;all&#8217; OR (string)&#8217;first&#8217;</p>
<p>This is why passing 0 doesn&#8217;t work or will yield ALL results. Find these lines in ActiveRecord.php (around 362-367) and add the === comparison operator (!== for bool NOT):</p>
<p>      if (is_array($id))<br />
        $where = &#8220;{$item-&gt;primary_key} IN (&#8221; . implode(&#8220;,&#8221;, $id) . &#8220;)&#8221;;<br />
      elseif ($id === &#8216;first&#8217;)<br />
        $limit = &#8217;1&#8242;;<br />
      elseif ($id !== &#8216;all&#8217;)<br />
        $where = &#8220;{$item-&gt;table_name}.{$item-&gt;primary_key} = $id&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Borja</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-31790</link>
		<dc:creator>Matt Borja</dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-31790</guid>
		<description>Also, I had to add/modify these lines to pass 0 as a parameter of User::find((int)$id) in the event none was specified.

After $select = &#039;*&#039; on Line 361 of ActiveRecord.php
      if(is_numeric($id)) 
        $where = &quot;{$item-&gt;table_name}.{$item-&gt;primary_key} = $id&quot;;
      elseif (is_array($id))
        $where = &quot;{$item-&gt;primary_key} IN (&quot; . implode(&quot;,&quot;, $id) . &quot;)&quot;;</description>
		<content:encoded><![CDATA[<p>Also, I had to add/modify these lines to pass 0 as a parameter of User::find((int)$id) in the event none was specified.</p>
<p>After $select = &#8216;*&#8217; on Line 361 of ActiveRecord.php<br />
      if(is_numeric($id))<br />
        $where = &#8220;{$item-&gt;table_name}.{$item-&gt;primary_key} = $id&#8221;;<br />
      elseif (is_array($id))<br />
        $where = &#8220;{$item-&gt;primary_key} IN (&#8221; . implode(&#8220;,&#8221;, $id) . &#8220;)&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Borja</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-31789</link>
		<dc:creator>Matt Borja</dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:09:49 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-31789</guid>
		<description>It appears that if you set more than one PRIMARY KEY, that Users::find($id) will look at the last PRIMARY KEY and I found the $where query in ActiveRecord::generate_find_query() to come out as follows:

WHERE: users.email = &#039;5&#039;

In my table, I have these fields set as PRIMARY KEYS in the following order:

id
username
email

Just wanted to give you a heads up. For my uses, I&#039;m going to [and might suggest] revising it to look at the first PRIMARY KEY which in most applications is going to be the AUTO_INCREMENT id field.

At any rate, this is why I was having this problem earlier; multiple PRIMARY KEYS.</description>
		<content:encoded><![CDATA[<p>It appears that if you set more than one PRIMARY KEY, that Users::find($id) will look at the last PRIMARY KEY and I found the $where query in ActiveRecord::generate_find_query() to come out as follows:</p>
<p>WHERE: users.email = &#8217;5&#8242;</p>
<p>In my table, I have these fields set as PRIMARY KEYS in the following order:</p>
<p>id<br />
username<br />
email</p>
<p>Just wanted to give you a heads up. For my uses, I&#8217;m going to [and might suggest] revising it to look at the first PRIMARY KEY which in most applications is going to be the AUTO_INCREMENT id field.</p>
<p>At any rate, this is why I was having this problem earlier; multiple PRIMARY KEYS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Borja</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-31788</link>
		<dc:creator>Matt Borja</dc:creator>
		<pubDate>Thu, 15 Sep 2011 16:01:07 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-31788</guid>
		<description>Is there a reason why this is throwing the following:

Couldn&#039;t find anything.

Code:
    public function view($id = NULL) {
        try {
            $u = User::find(1);
        } catch (Exception $e) {
            echo $e-&gt;getMessage();
        }

        if (isset($u))
            echo &#039;Found &#039; . $u-&gt;username;
    }</description>
		<content:encoded><![CDATA[<p>Is there a reason why this is throwing the following:</p>
<p>Couldn&#8217;t find anything.</p>
<p>Code:<br />
    public function view($id = NULL) {<br />
        try {<br />
            $u = User::find(1);<br />
        } catch (Exception $e) {<br />
            echo $e-&gt;getMessage();<br />
        }</p>
<p>        if (isset($u))<br />
            echo &#8216;Found &#8216; . $u-&gt;username;<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elia</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-25170</link>
		<dc:creator>Elia</dc:creator>
		<pubDate>Fri, 21 Jan 2011 08:37:21 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-25170</guid>
		<description>Thanks for providing this excellent lib! Is there an easy way to debug the SQL generated?</description>
		<content:encoded><![CDATA[<p>Thanks for providing this excellent lib! Is there an easy way to debug the SQL generated?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-25127</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Thu, 13 Jan 2011 00:53:45 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-25127</guid>
		<description>Shawn, I can&#039;t think of a great way to do that.  You could do something like query the Tracks that are released and then get the albums associated with those tracks.  If you require that the album have to verify that ALL of its tracks are &#039;released&#039;, then you&#039;d probably have to do that in your PHP.  Something like:

$tracks = Track::find(&#039;all&#039;, array(&#039;conditions&#039; =&gt; &quot;status = &#039;released&#039;&quot;, &#039;include&#039; =&gt; &#039;album&#039;));

next you&#039;d have to loop through the tracks, grab all unique albums and verify that all their tracks have a status of &#039;released&#039;.  If that hurts performance-wise, you may have to do a manual SQL query.</description>
		<content:encoded><![CDATA[<p>Shawn, I can&#8217;t think of a great way to do that.  You could do something like query the Tracks that are released and then get the albums associated with those tracks.  If you require that the album have to verify that ALL of its tracks are &#8216;released&#8217;, then you&#8217;d probably have to do that in your PHP.  Something like:</p>
<p>$tracks = Track::find(&#8216;all&#8217;, array(&#8216;conditions&#8217; => &#8220;status = &#8216;released&#8217;&#8221;, &#8216;include&#8217; => &#8216;album&#8217;));</p>
<p>next you&#8217;d have to loop through the tracks, grab all unique albums and verify that all their tracks have a status of &#8216;released&#8217;.  If that hurts performance-wise, you may have to do a manual SQL query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn McCool</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-25125</link>
		<dc:creator>Shawn McCool</dc:creator>
		<pubDate>Wed, 12 Jan 2011 20:39:59 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-25125</guid>
		<description>If, for example, each record in the data model &#039;albums&#039; connects to a number of records in the &#039;tracks&#039; table.  Is there a way to pull back albums such that it has only tracks marked as &#039;released&#039;?

Currently:

$album = Album::Find(1);
print_r($album-&gt;tracks); // lists ALL items

I only want to list items with a condition.</description>
		<content:encoded><![CDATA[<p>If, for example, each record in the data model &#8216;albums&#8217; connects to a number of records in the &#8216;tracks&#8217; table.  Is there a way to pull back albums such that it has only tracks marked as &#8216;released&#8217;?</p>
<p>Currently:</p>
<p>$album = Album::Find(1);<br />
print_r($album-&gt;tracks); // lists ALL items</p>
<p>I only want to list items with a condition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn McCool</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-25113</link>
		<dc:creator>Shawn McCool</dc:creator>
		<pubDate>Sun, 09 Jan 2011 20:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-25113</guid>
		<description>You can create a hook before_create() and before_save() to update the fields &quot;created_at&quot; and &quot;updated_at&quot;.</description>
		<content:encoded><![CDATA[<p>You can create a hook before_create() and before_save() to update the fields &#8220;created_at&#8221; and &#8220;updated_at&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn McCool</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-24981</link>
		<dc:creator>Shawn McCool</dc:creator>
		<pubDate>Sat, 11 Dec 2010 02:30:59 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-24981</guid>
		<description>Does this support any kind of automatic timestamp such as created_at or updated_at?</description>
		<content:encoded><![CDATA[<p>Does this support any kind of automatic timestamp such as created_at or updated_at?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalle</title>
		<link>http://lukebaker.org/projects/activerecord-in-php/documentation/comment-page-1/#comment-24484</link>
		<dc:creator>Kalle</dc:creator>
		<pubDate>Thu, 14 Oct 2010 11:14:09 +0000</pubDate>
		<guid isPermaLink="false">http://lukebaker.org/projects/activerecord-in-php/documentation/#comment-24484</guid>
		<description>Hi again..!

I just echo:ed the SQL generated by...
Movie::find(‘all’, array(’select’ =&gt; ‘*, sum(movieratings.rating) as sum_rating’, ‘group’ =&gt; ‘movie.id’, ‘include’ =&gt; ‘movieratings’));

If I use the options &quot;include&quot; AND &quot;select&quot; I can write whatever I want in the &quot;select&quot; option. It doesn&#039;t matter because the generated SQL will contain ALL column names.

Movie::find(‘all’, array(’select’ =&gt; ‘movies.id, movies.title’));
...gives me a query for just the specified columns. BUT...!

Movie::find(‘all’, array(’select’ =&gt; ‘movies.id, movies.title’, ‘include’ =&gt; ‘movieratings’));
...creates a select including ALL columns in both the movies table and the movieratings table.

This must be a bug... Or am I just using the framework wrong? 

Anyone? 

Help?

Thanks!

{Kalle}</description>
		<content:encoded><![CDATA[<p>Hi again..!</p>
<p>I just echo:ed the SQL generated by&#8230;<br />
Movie::find(‘all’, array(’select’ =&gt; ‘*, sum(movieratings.rating) as sum_rating’, ‘group’ =&gt; ‘movie.id’, ‘include’ =&gt; ‘movieratings’));</p>
<p>If I use the options &#8220;include&#8221; AND &#8220;select&#8221; I can write whatever I want in the &#8220;select&#8221; option. It doesn&#8217;t matter because the generated SQL will contain ALL column names.</p>
<p>Movie::find(‘all’, array(’select’ =&gt; ‘movies.id, movies.title’));<br />
&#8230;gives me a query for just the specified columns. BUT&#8230;!</p>
<p>Movie::find(‘all’, array(’select’ =&gt; ‘movies.id, movies.title’, ‘include’ =&gt; ‘movieratings’));<br />
&#8230;creates a select including ALL columns in both the movies table and the movieratings table.</p>
<p>This must be a bug&#8230; Or am I just using the framework wrong? </p>
<p>Anyone? </p>
<p>Help?</p>
<p>Thanks!</p>
<p>{Kalle}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.239 seconds -->

