Comments on: CakePHP 1.2 tip of the day: be mindful of Model::set /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/?utm_source=rss&utm_medium=rss&utm_campaign=cakephp-1-2-tip-of-the-day-be-mindful-of-modelset A glimpse at a coder's troubled mind Sun, 07 Apr 2013 02:38:13 +0000 hourly 1 http://wordpress.org/?v=3.6 By: cakeUser /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/comment-page-1/#comment-31493 cakeUser Sun, 16 Dec 2012 14:39:55 +0000 /1/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/#comment-31493 old post but a damn good trick, this explains to me a lot.
Thanx

]]>
By: Ahmad /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/comment-page-1/#comment-14113 Ahmad Tue, 21 Jun 2011 13:27:40 +0000 /1/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/#comment-14113 u save my live :)

]]>
By: PHPSC [Visitor] /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/comment-page-1/#comment-114 PHPSC [Visitor] Thu, 18 Oct 2007 19:58:00 +0000 /1/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/#comment-114 I have to say i agree with Daniel. If there is something which is generally misunderstood by everyone then maybe it should be named better.

Regarding using the “create” function that can be a problem when u want to update the data after validation instead of inserting a new record. Thats because in 1.2 “create” also retrieves the default values set for a field from the table definition. So it will update a field with default value even if i don’t want to. I am still an amateur in cakePHP so please correct me if i am wrong.

]]>
By: Daniel Hofstetter [Visitor] /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/comment-page-1/#comment-113 Daniel Hofstetter [Visitor] Mon, 01 Oct 2007 08:05:00 +0000 /1/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/#comment-113 That’s not what I am saying. What I am saying is that I don’t expect that the arrays get merged if I have something like:

$this->set($arrayA);
$this->set($arrayB);

The semantic is not correct and so people get it wrong. But if I have something like

$this->set(‘var1′, $value1);
$this->set(‘var2′, $value2);

then I expect both variables in the view.

If you want to see my comments as complaining, then see it as complaining, even though it is meant as feedback.

]]>
By: mariano.iglesias [Member] /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/comment-page-1/#comment-112 mariano.iglesias [Member] Sun, 30 Sep 2007 16:40:00 +0000 /1/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/#comment-112 @Daniel: I completely disagree. But then again you know that already, and for some reason you are only but complaining lately so I think there’s no need for a debate. In any way, Model::set behaves exactly as Controller::set. And what you are asking is that in controller if you do:

$this->set(‘var1′, ‘value1′);

and then later on:

$this->set(‘var2′, ‘value2′);

Then only var2 will be available in the view. Ask ANY baker in the world and they’ll say THAT’S CRAP, regardless of what YOU deem as adequate for the method.

]]>
By: Daniel Hofstetter [Visitor] /cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/comment-page-1/#comment-111 Daniel Hofstetter [Visitor] Sun, 30 Sep 2007 11:04:00 +0000 /1/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/#comment-111 Well, I think if something is a common misunderstanding then it is probably the framework’s fault. If I see a set method then I expect it sets the provided data, but not that it merges them with some existing data (then the method should be named “add” for example). So to me the set method you showed simply violates the convention for set methods.

]]>