I was getting a similar problem when I was using saveField.  In Cake
1.2.4605 alpha I used a saveField call while updating my Category
model.  The SQL command would look like this:

UPDATE `categories` SET `options` = 'a:2:{i:0;s:1:\"0\";i:1;s:
0:\"\";}' WHERE `id` IN (66)

and work just fine.

Whereas in Cake 1.2.5875 pre-beta, the same command would result in
the SQL line:

UPDATE `categories` SET `id` = 67,`parent_id` = 66,`numberOfChildren`
= NULL,`options` = 'a:2:{i:0;s:1:\"0\";i:1;s:0:\"\";}',`name` =
'Default',`teaser` = NULL,`description` = NULL,`model` =
'Image',`ordering` = 1,`created` = '2007-08-27 17:33:24',`modified` =
'2007-08-27 17:33:24' WHERE `id` IN (66)

Notice it would set the category ID incorrectly, as well as update the
entire entry, which sounds similar to what's happening to you.

I fixed this by moving from saveField to the model save function, as
such:
$saveData = array('Category'=>array('id'=>$category['ParentCategory']
['id'],'options'=>serialize($options)));
$this->Image->Category-
>save($saveData,false,array('Category.options'));

And that seemed to work.

So in your case, try:
$saveData = array('Category'=>array('id'=>$category_id,'title'=>
$title));
$this->Category->save($saveData,false,array('Category.title'));

And hopefully that will work for you.


On Oct 26, 4:58 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I have model Category with fields:
>
> id
> title
> parent_id
>
> (yep category with subcategory, like threaded in bakery).
> In model I don't put any belongs/has... base, empty model...
>
> Ok.
>
> So, when I change title by saveField
>
> $this->Category->saveField('title',$title);
>
> I see this query:
>
> UPDATE `categories` SET `parent_id` = '0',`title` = 'My new title'
> WHERE `id` IN (1)
>
> So, WHY I get "parent_id = 0", Why???


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to