hi,is it one bug is model?

2009-07-14 Thread marscode

Under the first note--My english is bad,so say sorry first to every
member.

ok, I find an eminently case in model method about save data into
database.

exapmple1
$this-data=array(
   'Modelname'=array(
'id' = '123',
'somefield'=0
)
);
$this-Modelname-save($this-data);

so the result in database,value of the field named 'somefield' is 0.

example2
$this-id=123;
$this-Modelname-save(array('somefield'=0));

in this example the field's value is NULL not 0.if the field is
disable null,cakephp will throw an error.

so ,i think it is one bug of Inconsistent about Semantic

last,thank cakephp team for them distribution an excellent php
framework.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: hi,is it one bug is model?

2009-07-14 Thread brian

example2
$this-id=123;
$this-Modelname-save(array('somefield'=0));

$this-ModelName-id = 123;

But I think you should also have

$this-ModelName-create();
$this-ModelName-id = 123;
$this-Modelname-save(array('somefield'=0));

try that

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: hi,is it one bug is model?

2009-07-14 Thread 3lancer.eu

Hi,

 Under the first note--My english is bad,so say sorry first to every
 member.

 ok, I find an eminently case in model method about save data into
 database.

 exapmple1
 $this-data=array(
        'Modelname'=array(
                 'id' = '123',
                 'somefield'=0
         )
 );
 $this-Modelname-save($this-data);

 so the result in database,value of the field named 'somefield' is 0.

 example2
 $this-id=123;
 $this-Modelname-save(array('somefield'=0));

How about:
$this-Modelname-save(array('Modelname'=array('id'=123,
'somefield'=0)));

If you call save in a loop, on every iteration use $this-Modelname-
create() as mentioned on:
http://book.cakephp.org/view/75/Saving-Your-Data

Regards,
Piotr
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---