I figured it out.and am sharing
instead of
//first part
$obj_Vendor = new Vendor();
$obj_Vendor->save($theData);
i used
//first part
$obj_Vendor = new Vendor();
$obj_Vendor->save($theData['Vendor']);
The code works perfectly like i need.
I got another solution also by using Model::create();
But i am a little bit confused with saveAll is a little bit confusing
i will look at that again.
Thanks for your help.
On Aug 19, 12:08 pm, teknoid <[EMAIL PROTECTED]> wrote:
> First way is an incorrect way of doing things in cake...
>
> If you need to save multiple rows use saveAll(), however the form
> fields will need to be named slightly different...
> You can refer to test cases for details on saveAll() usage, or take a
> look here (maybe part 2 is more applicable for
> you):http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part...
>
> On Aug 19, 1:07 pm, Mahesh <[EMAIL PROTECTED]> wrote:
>
> > i have a model name Vendor.
> > class Vendor extends AppModel
> > {
> > var $name = 'vendor';
> > var $hasMany = array(
> > 'VendorProduct' => array(
> > 'className' => 'VendorProduct',
> > 'foreignKey' => 'vendor_id',
> > 'dependent'=> true
> > )
> > );}
>
> > i have created a function upload in the controller
> > function upload()
> > {
> > //first part
> > $obj_Vendor = new Vendor();
> > $obj_Vendor->save($theData);
> > //second part
> > $theData = Array('Vendor' => Array('name' => 'test1'));
> > $this->Vendor->save($theData);
>
> > }
>
> > Actually the problem is the second part is working correctly. But the
> > first is not.
> > The problem i have more than one row to be inserted. when i am doing
> > through the second way it's actually updating instead of inserting.
> > Could anyone help me??? Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---