Try using after save statement.

$this->Contacts->getLastinserID();


Regards,
Guru Prasad.K.V
Let's be realistic, demand the impossible!
On Dec 15, 2014 11:43 PM, "Radharadhya Dasa" <[email protected]> wrote:

> Hi,
>
> I want to save a new contact. The contacts has skills (belongsToMany).
> Skill is a text input and with jquery autocomplete I search for existing
> skills. If the user select existing skills their id is sent to to
> controller, if they create new skills the controller gets their names
> starting with a "~" char.
>
> So my controller gets something like this:
> /*debug($this->request->data);
>   'name' => 'John Doe',
>   'email' => '[email protected]',
>   'skills' => [
>     '_ids' => [
>       (int) 0 => '1',            //found in skills, this is the id
>       (int) 1 => '~könyvelő'     //starts with "~" this is a new skill (or
> fast typer problem)
>     ]
>   ]
> */
>
>
> If I have no new skill (a skill what starts with "~") I can do the
> following:
>
> $contact = $this->Contacts->newEntity($this->request->data);
> this->Contacts->save($contact);
>
> But if I have new skill I should save it first, get the corresponding id,
> replace the name with the id and than I could save it. Is it the way? I did
> not find any way to get the last inserted id.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to