you need to use $data = $this->ModelName->create(); this populates the model with the default data and created the structure for the data.
For example if you have a table model with the following structure id int name varchar(100) defaul 'My Name' age int(3) default 12 Then using $data = $this->Model->create(); would give $data['Model']['name']= 'My Name'; $data['Model'][age'] = 12; You could then set $data['Model']['age'] = 42; then save the data $this->Model->save($data); this would then save to the database;; On Jul 11, 2:44 pm, KiANIi <[EMAIL PROTECTED]> wrote: > I've tried the solution you have suggested but its not working the > problem is not with saving of data but when I try to search data at > the start of each iteration data is not found in table so it returns > an empty array. is there any other solution to that problem > > Samuel DeVore wrote: > > before each save use create > > > $this->ModelName->create(); > > $this->ModelName->save($data); > > > see the section in the manual on saving data > > >http://book.cakephp.org/view/75/saving-your-data > > > sam d > > -- > > (the old fart) the advice is free, the lack of crankiness will cost you > > > - its a fine line between a real question and an idiot > > >http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ > >http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/ > >http://blog.samdevore.com/cakephp-pages/i-cant-bake/ > > > On Thu, Jul 3, 2008 at 10:38 AM, KiANIi <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > I'm trying to save data using $this->modelName->save(data) in a loop > > > but after the end of each iteration when I'm trying to find the data > > > that I've inserted I could not find that data. > > > > Can anyone tell me how i can save data in table in loop. > > > > the code is: > > > > $this-model = $this->controller->modelName; > > > for ($i =0 ; $i<4;$i++) > > > { > > > echo 'Iteration # '.$i; > > > $this->model->save($distributedImp); > > > $res = $this->model->findAll(); > > > print_r($res); > > > } --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---