|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Problem with saveAll() and beforeSave() - did not remember changes?Hi, I've pasted code here: http://bin.cakephp.org/saved/52122 The problem is that the saveAll() doesn't work at all. Ok, it's invoked and $this->data is modified, but saveAll() does not save any records and debug($this->data) after success of saveAll() shows the old structure of $this->data. What I'm doing wrong? Please help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Problem with saveAll() and beforeSave() - did not remember changes?Oh, the table structure is: settings(id, key, value, created, modified) key & value are of course VARCHARS. On 2 Lis, 11:04, red <mbu...@...> wrote: > Hi, > I've pasted code here:http://bin.cakephp.org/saved/52122 > > The problem is that the saveAll() doesn't work at all. Ok, it's > invoked and $this->data is modified, but saveAll() does not save any > records and debug($this->data) after success of saveAll() shows the > old structure of $this->data. What I'm doing wrong? > > Please help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Problem with saveAll() and beforeSave() - did not remember changes?And is "key" unique, but not validated against? Since there are no IDs included, saveAll() will try to create the entries which could be why it fails. Try copying the generated queries from the SQL log and running them from phpMyAdmin for more detailed error messages. On Nov 2, 6:16 pm, red <mbu...@...> wrote: > Oh, the table structure is: > settings(id, key, value, created, modified) > > key & value are of course VARCHARS. > > On 2 Lis, 11:04, red <mbu...@...> wrote: > > > Hi, > > I've pasted code here:http://bin.cakephp.org/saved/52122 > > > The problem is that the saveAll() doesn't work at all. Ok, it's > > invoked and $this->data is modified, but saveAll() does not save any > > records and debug($this->data) after success of saveAll() shows the > > old structure of $this->data. What I'm doing wrong? > > > Please help. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Problem with saveAll() and beforeSave() - did not remember changes?Even if I remove the unique key from table, Cake is not inserting. In logs I have: START TRANSACTION COMMIT No other SQL queries, any INSERT nor UPDATE. On 2 Lis, 11:59, Robert P <shiftyrobs...@...> wrote: > And is "key" unique, but not validated against? > > Since there are no IDs included, saveAll() will try to create the > entries which could be why it fails. Try copying the generated queries > from the SQL log and running them from phpMyAdmin for more detailed > error messages. > > On Nov 2, 6:16 pm, red <mbu...@...> wrote: > > > > > Oh, the table structure is: > > settings(id, key, value, created, modified) > > > key & value are of course VARCHARS. > > > On 2 Lis, 11:04, red <mbu...@...> wrote: > > > > Hi, > > > I've pasted code here:http://bin.cakephp.org/saved/52122 > > > > The problem is that the saveAll() doesn't work at all. Ok, it's > > > invoked and $this->data is modified, but saveAll() does not save any > > > records and debug($this->data) after success of saveAll() shows the > > > old structure of $this->data. What I'm doing wrong? > > > > Please help. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Problem with saveAll() and beforeSave() - did not remember changes?I think you must convert array structure before save call. saveAll function determine the way must be used for actual save before beforeSave is called. So saveAll thinks that it should save one record of one structure, but then you change it to many records of other structure. So save fails. Make your own mySave method, convert array there and then call saveAll. On Nov 2, 4:04 pm, red <mbu...@...> wrote: > Hi, > I've pasted code here:http://bin.cakephp.org/saved/52122 > > The problem is that the saveAll() doesn't work at all. Ok, it's > invoked and $this->data is modified, but saveAll() does not save any > records and debug($this->data) after success of saveAll() shows the > old structure of $this->data. What I'm doing wrong? > > Please help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Problem with saveAll() and beforeSave() - did not remember changes?Thanks Dr. Loboto for your answer - I've already done like that. Function prepareToSaveAll that takes some array and returns converted. On 3 Lis, 04:25, "Dr. Loboto" <drlob...@...> wrote: > I think you must convert array structure before save call. saveAll > function determine the way must be used for actual save before > beforeSave is called. So saveAll thinks that it should save one record > of one structure, but then you change it to many records of other > structure. So save fails. Make your own mySave method, convert array > there and then call saveAll. > > On Nov 2, 4:04 pm, red <mbu...@...> wrote: > > > > > Hi, > > I've pasted code here:http://bin.cakephp.org/saved/52122 > > > The problem is that the saveAll() doesn't work at all. Ok, it's > > invoked and $this->data is modified, but saveAll() does not save any > > records and debug($this->data) after success of saveAll() shows the > > old structure of $this->data. What I'm doing wrong? > > > Please help. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@... To unsubscribe from this group, send email to cake-php+unsubscribe@... For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |