<?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: Finding Random Model Records in CakePHP 1.2</title>
	<atom:link href="http://jamienay.com/2009/11/finding-random-model-records-in-cakephp-1-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamienay.com/2009/11/finding-random-model-records-in-cakephp-1-2/</link>
	<description>A PHP web developer writing about the web.</description>
	<lastBuildDate>Mon, 26 Jul 2010 20:07:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: mark</title>
		<link>http://jamienay.com/2009/11/finding-random-model-records-in-cakephp-1-2/comment-page-1/#comment-6828</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Fri, 18 Jun 2010 20:41:07 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=465#comment-6828</guid>
		<description>by the way:
caching the primary keys might actually make your method 100x faster... 
usually those records dont change that often. and new ones dont have to appear right away.
maybe by enabling &quot;cache&quot;=&gt;true/false as parameter?</description>
		<content:encoded><![CDATA[<p>by the way:<br />
caching the primary keys might actually make your method 100x faster&#8230;<br />
usually those records dont change that often. and new ones dont have to appear right away.<br />
maybe by enabling &#8220;cache&#8221;=&gt;true/false as parameter?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mark</title>
		<link>http://jamienay.com/2009/11/finding-random-model-records-in-cakephp-1-2/comment-page-1/#comment-6827</link>
		<dc:creator>mark</dc:creator>
		<pubDate>Fri, 18 Jun 2010 20:37:25 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=465#comment-6827</guid>
		<description>nice idea
but i ended up with using sql internal RAND() because its way faster - especially if the records are getting more and more...

	function __findRandom($options) {
		$type = &#039;first&#039;;
		if (isset($options[&#039;type&#039;]) &amp;&amp; $options[&#039;type&#039;] != &#039;random&#039;) {
			$type = $options[&#039;type&#039;];
			unset($options[&#039;type&#039;]);
		}
		$options[&#039;order&#039;] = &#039;rand()&#039;;
		return $this-&gt;find($type, $options);
	}</description>
		<content:encoded><![CDATA[<p>nice idea<br />
but i ended up with using sql internal RAND() because its way faster &#8211; especially if the records are getting more and more&#8230;</p>
<p>	function __findRandom($options) {<br />
		$type = &#8216;first&#8217;;<br />
		if (isset($options['type']) &amp;&amp; $options['type'] != &#8216;random&#8217;) {<br />
			$type = $options['type'];<br />
			unset($options['type']);<br />
		}<br />
		$options['order'] = &#8216;rand()&#8217;;<br />
		return $this-&gt;find($type, $options);<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie</title>
		<link>http://jamienay.com/2009/11/finding-random-model-records-in-cakephp-1-2/comment-page-1/#comment-4549</link>
		<dc:creator>Jamie</dc:creator>
		<pubDate>Tue, 19 Jan 2010 15:28:40 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=465#comment-4549</guid>
		<description>Thanks Selino - looks like I forgot the closing brace for the class. Also, you&#039;ll need to have support for custom find methods, which I should&#039;ve included in the code. I&#039;ve updated the code on Github to fix both issues.</description>
		<content:encoded><![CDATA[<p>Thanks Selino &#8211; looks like I forgot the closing brace for the class. Also, you&#8217;ll need to have support for custom find methods, which I should&#8217;ve included in the code. I&#8217;ve updated the code on Github to fix both issues.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Selino</title>
		<link>http://jamienay.com/2009/11/finding-random-model-records-in-cakephp-1-2/comment-page-1/#comment-4546</link>
		<dc:creator>Selino</dc:creator>
		<pubDate>Tue, 19 Jan 2010 08:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://jamienay.com/?p=465#comment-4546</guid>
		<description>Warning (512): SQL Error: 1054: Unknown column &#039;random&#039; in &#039;where clause&#039;

This is what I get when I execute : $this-&gt;set(&#039;tip&#039;, $this-&gt;Tip-&gt;find(&#039;random&#039;));

It looks like it&#039;s not seeing &#039;random&#039; as an option but as a field.

I also had to add a  } to the function. When I do a balance braces on the githup code it shows that the parent function definition is not closed.</description>
		<content:encoded><![CDATA[<p>Warning (512): SQL Error: 1054: Unknown column &#8216;random&#8217; in &#8216;where clause&#8217;</p>
<p>This is what I get when I execute : $this-&gt;set(&#8216;tip&#8217;, $this-&gt;Tip-&gt;find(&#8216;random&#8217;));</p>
<p>It looks like it&#8217;s not seeing &#8216;random&#8217; as an option but as a field.</p>
<p>I also had to add a  } to the function. When I do a balance braces on the githup code it shows that the parent function definition is not closed.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
