<?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: CakePHP Sequence Behavior</title>
	<atom:link href="http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/</link>
	<description>Learnings and Teachings on Web Application Development &#38; CakePHP</description>
	<lastBuildDate>Tue, 09 Mar 2010 23:55:11 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7874</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Tue, 09 Mar 2010 23:55:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7874</guid>
		<description>@craig, thanks for that, what might work is merging the values for old groups and new groups before passing it to _getHighestOrder().

E.g. in beforeSave() &gt; Editing &gt; Changing group &gt; Order not specified section, change it to:

// Insert at end of new group
$model-&gt;data[$model-&gt;alias][$orderField] = $this-&gt;_getHighestOrder(
  $model,
  array_merge(
    $this-&gt;_oldGroups[$model-&gt;alias]
    $this-&gt;_newGroups[$model-&gt;alias]
  )
) + 1;

I&#039;ll check it out when I get chance, and add it with suitable test cases.</description>
		<content:encoded><![CDATA[<p>@craig, thanks for that, what might work is merging the values for old groups and new groups before passing it to _getHighestOrder().</p>
<p>E.g. in beforeSave() > Editing > Changing group > Order not specified section, change it to:</p>
<p>// Insert at end of new group<br />
$model->data[$model->alias][$orderField] = $this->_getHighestOrder(<br />
  $model,<br />
  array_merge(<br />
    $this->_oldGroups[$model->alias]<br />
    $this->_newGroups[$model->alias]<br />
  )<br />
) + 1;</p>
<p>I&#8217;ll check it out when I get chance, and add it with suitable test cases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: craig</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7870</link>
		<dc:creator>craig</dc:creator>
		<pubDate>Tue, 09 Mar 2010 21:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7870</guid>
		<description>Great behavior -- Just what I needed!

fwiw, I&#039;m grouping on three columns, and I find that I need to specify the value for each of the three when I want to change the value of any one of them. That is, if I change the value of one grouping field, I need to also provide the existing values for the other two fields when I update the record. 

Otherwise _getHighestOrder() will not find any matching records, and will use the default start_at order number.

This is probably the expected behavior, but I thought I&#039;d mention it.</description>
		<content:encoded><![CDATA[<p>Great behavior &#8212; Just what I needed!</p>
<p>fwiw, I&#8217;m grouping on three columns, and I find that I need to specify the value for each of the three when I want to change the value of any one of them. That is, if I change the value of one grouping field, I need to also provide the existing values for the other two fields when I update the record. </p>
<p>Otherwise _getHighestOrder() will not find any matching records, and will use the default start_at order number.</p>
<p>This is probably the expected behavior, but I thought I&#8217;d mention it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7633</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Mon, 22 Feb 2010 23:32:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7633</guid>
		<description>@Aurimas, thanks, I&#039;ll check it out.</description>
		<content:encoded><![CDATA[<p>@Aurimas, thanks, I&#8217;ll check it out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aurimas</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7623</link>
		<dc:creator>Aurimas</dc:creator>
		<pubDate>Mon, 22 Feb 2010 09:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7623</guid>
		<description>Hello, 

Thanks for fixing some problems, but found some new ^^. If both belonging models have sequence behaviour i was getting fatal error. 

Fatal error: [] operator not supported for strings in C:\..\cake\libs\model\datasources\dbo_source.php  on line 1126

For ex. User belongsTo Group and  both have behaviour attached.
Have find quick fix 171 line change:
$queryData[&#039;order&#039;]
to
$queryData[&#039;order&#039;][]

i would commit changes but never used git ^^

Regards,
Aurimas</description>
		<content:encoded><![CDATA[<p>Hello, </p>
<p>Thanks for fixing some problems, but found some new ^^. If both belonging models have sequence behaviour i was getting fatal error. </p>
<p>Fatal error: [] operator not supported for strings in C:\..\cake\libs\model\datasources\dbo_source.php  on line 1126</p>
<p>For ex. User belongsTo Group and  both have behaviour attached.<br />
Have find quick fix 171 line change:<br />
$queryData['order']<br />
to<br />
$queryData['order'][]</p>
<p>i would commit changes but never used git ^^</p>
<p>Regards,<br />
Aurimas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7413</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Thu, 11 Feb 2010 22:52:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7413</guid>
		<description>@prgTW, nice one, thanks for your contribution. I&#039;ll add the methods as soon as I get chance.</description>
		<content:encoded><![CDATA[<p>@prgTW, nice one, thanks for your contribution. I&#8217;ll add the methods as soon as I get chance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prgTW</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7404</link>
		<dc:creator>prgTW</dc:creator>
		<pubDate>Thu, 11 Feb 2010 01:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7404</guid>
		<description>http://pastebin.com/f7a5bbae9

I&#039;ve added moveUp() and moveDown() functions for moving an element so it could be compatible with the core CakePHP TreeBehavior. Hope You enjoy :).

@Neil
You could merge it into Your behavior on github :)</description>
		<content:encoded><![CDATA[<p><a href="http://pastebin.com/f7a5bbae9" rel="nofollow">http://pastebin.com/f7a5bbae9</a></p>
<p>I&#8217;ve added moveUp() and moveDown() functions for moving an element so it could be compatible with the core CakePHP TreeBehavior. Hope You enjoy :).</p>
<p>@Neil<br />
You could merge it into Your behavior on github :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Neil Crookes</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7157</link>
		<dc:creator>Neil Crookes</dc:creator>
		<pubDate>Wed, 27 Jan 2010 00:43:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7157</guid>
		<description>@Aurimas thanks for the comment, I&#039;ll check it out. Going to try and fine the time to refactor the behavior into a plugin so it can be added to project more easily. I think you&#039;re right, there are some funny things going on when you have it attached to lots of models and you are doing multiple save operations on more than one of them, perhaps triggered by callbacks on other models. I&#039;ll have a look at this at the same time.</description>
		<content:encoded><![CDATA[<p>@Aurimas thanks for the comment, I&#8217;ll check it out. Going to try and fine the time to refactor the behavior into a plugin so it can be added to project more easily. I think you&#8217;re right, there are some funny things going on when you have it attached to lots of models and you are doing multiple save operations on more than one of them, perhaps triggered by callbacks on other models. I&#8217;ll have a look at this at the same time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aurimas</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-7144</link>
		<dc:creator>Aurimas</dc:creator>
		<pubDate>Tue, 26 Jan 2010 11:21:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-7144</guid>
		<description>Nice and usefull behaviour, but i found some problems with it.
at behaviour  _setup() on line 171
$model-&gt;order = $this-&gt;escapedOrderField = $model-&gt;escapeField($this-&gt;orderField); 

escapedOrderField is not correctly set. If use behaviour at many models. I was getting incorectly generated query, it was strange that in query was values from other model which is not belong to current model in any way. So figured out that it was problem in 
$this-&gt;update = array(
            &#039;action&#039; =&gt; array(
              $this-&gt;escapedOrderField =&gt; $this-&gt;escapedOrderField . &#039; + 1&#039;
            ),
            &#039;conditions&#039; =&gt; array(
              array($this-&gt;escapedOrderField . &#039; &gt;=&#039; =&gt; $this-&gt;newOrder),
              array($this-&gt;escapedOrderField . &#039;  $this-&gt;oldOrder),
            ),
 ); 
as it uses $this-&gt;escapeOrderField,  and value was always the same model not currently updating. 
Fixed it by moving escapeOrderField initialization to setSaveUpdateData method, and it is working fine.

Don&#039;t know if it good way to solve this, as escapedOrderField is used also on other methods. Just take a look ;)

Thanks,
Aurimas</description>
		<content:encoded><![CDATA[<p>Nice and usefull behaviour, but i found some problems with it.<br />
at behaviour  _setup() on line 171<br />
$model-&gt;order = $this-&gt;escapedOrderField = $model-&gt;escapeField($this-&gt;orderField); </p>
<p>escapedOrderField is not correctly set. If use behaviour at many models. I was getting incorectly generated query, it was strange that in query was values from other model which is not belong to current model in any way. So figured out that it was problem in<br />
$this-&gt;update = array(<br />
            &#8216;action&#8217; =&gt; array(<br />
              $this-&gt;escapedOrderField =&gt; $this-&gt;escapedOrderField . &#8216; + 1&#8242;<br />
            ),<br />
            &#8216;conditions&#8217; =&gt; array(<br />
              array($this-&gt;escapedOrderField . &#8216; &gt;=&#8217; =&gt; $this-&gt;newOrder),<br />
              array($this-&gt;escapedOrderField . &#8216;  $this-&gt;oldOrder),<br />
            ),<br />
 );<br />
as it uses $this-&gt;escapeOrderField,  and value was always the same model not currently updating.<br />
Fixed it by moving escapeOrderField initialization to setSaveUpdateData method, and it is working fine.</p>
<p>Don&#8217;t know if it good way to solve this, as escapedOrderField is used also on other methods. Just take a look ;)</p>
<p>Thanks,<br />
Aurimas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Useful CakePHP Tutorial Roundup for June 26, 2009</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-6200</link>
		<dc:creator>Useful CakePHP Tutorial Roundup for June 26, 2009</dc:creator>
		<pubDate>Sun, 15 Nov 2009 22:24:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-6200</guid>
		<description>[...] CakePHP Sequence Behavior - Neil Crookes (February 9, 2009) Like so many other features, I was researching the best way to handle re-ordering of records via a CMS (e.g. so a user can change the order of photos in a gallery) when I chanced upon Neil&#8217;s handy little model behavior. His implementation is pretty smart in that it only executes database queries when it absolutely needs to, rather than just updating every record in a group when any order is changed. Throw in some JQuery AJAX drag and drop that Neil also provides - I&#8217;ve been a Prototype/Scriptaculous guy for a long time, but this is easy as pie! - and you&#8217;ve got a great re-ordering system in no time. [...]</description>
		<content:encoded><![CDATA[<p>[...] CakePHP Sequence Behavior &#8211; Neil Crookes (February 9, 2009) Like so many other features, I was researching the best way to handle re-ordering of records via a CMS (e.g. so a user can change the order of photos in a gallery) when I chanced upon Neil&#8217;s handy little model behavior. His implementation is pretty smart in that it only executes database queries when it absolutely needs to, rather than just updating every record in a group when any order is changed. Throw in some JQuery AJAX drag and drop that Neil also provides &#8211; I&#8217;ve been a Prototype/Scriptaculous guy for a long time, but this is easy as pie! &#8211; and you&#8217;ve got a great re-ordering system in no time. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Koschützki</title>
		<link>http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/comment-page-1/#comment-6152</link>
		<dc:creator>Tim Koschützki</dc:creator>
		<pubDate>Tue, 10 Nov 2009 07:14:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.neilcrookes.com/?p=164#comment-6152</guid>
		<description>Good stuff Neil!

I am going to try this in a project soon.

Thanks or sharing.</description>
		<content:encoded><![CDATA[<p>Good stuff Neil!</p>
<p>I am going to try this in a project soon.</p>
<p>Thanks or sharing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
