Friday, July 27, 2012

Re: How can I get the ID of a Post as its saved for the first time?

If I'm not mistaken the id of the latest saved record is $this->model->id   

"Value of the primary key ID of the record that this model is currently pointing to. Automatically set after database insertions."

There's also the two functions getInsertID ( http://api20.cakephp.org/class/model#method-ModelgetInsertID ) and getLastInsertID ( http://api20.cakephp.org/class/model#method-ModelgetLastInsertID ) though I cannot tell you the difference between those two.

Hope that helps :) 

Am Freitag, 27. Juli 2012 11:43:52 UTC+2 schrieb bigjimmi:
Is it possible within a Add() function to find the ID of a post just as its written to the DB?

Basically I'm trying to create a ACO for the post when its saved by doing something like this:

$aco = $this->Acl->Aco->create(Array('model'=>Post, foreign_key=>'XXXX'));

Where XXXX is the ID of the post that's just been saved within the same function.

Thanks in advance

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: