Hi group,
I'm not sure if I'm misunderstoonding something or if I've found a bug
in /libs/model/model.php.
It happens when I use saveAll() to save a bunch of records of the same
model:
$this->Mymodel->saveAll($this->data['Mymodel'], array('validate' =>
'first'))
This should do two things:
1.- Validate all the records in the $this->data array.
2.- If all the records validate, save them all. Otherwise, return
FALSE without saving anything.
But this is not happening. Let's think about a model with a "number"
field which has to be numeric to validate:
$this->data=array(
'Mymodel' => array(
'0' => array('number' => '5.00'),
'1' => array('number' => 'THIS IS INVALID !!!'),
'2' => array('number' => '10.00'),
)
);
if ($this->Mymodel->saveAll($this->data['Mymodel'], array('validate'
=> 'first')))
die('OK');
else
die('FAIL');
The result is a "FAIL" message, as expected BUT the first of the
records is saved:
START TRANSACTION (Affected: 0)
INSERT INTO `table` (...fields...) VALUES (..., '5.00',...)
(Affected: 1)
SELECT LAST_INSERT_ID() AS insertID (Affected: 1)
ROLLBACK (Affected: 0)
The result is that saveAll() only makas a PARTIAL save of the bunch of
records, because it's not correctly validating the data BEFORE
starting to save!
Any clue?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---