开发者

Is it possible to retrieve the ID of a new topic immediately after adding into the database?

开发者 https://www.devze.com 2023-01-05 09:50 出处:网络
I have some data recieved from a simple HTML form like this: $newdata = array(\'Testing\'=>array( \'topic\'=>$data[\'Testing\'][\'topic\'],

I have some data recieved from a simple HTML form like this:

$newdata =
array('Testing'=>array(
'topic'=>$data['Testing']['topic'], 
'content'=>$data['Testing']['content']),
'new'=>$data['Testing']['new'])
                 ); 

The data has been added into the database using this line of code:

$this->Testing->save($newdata);

The data has been added into the database successfully,

but I am not sure if it is possible to retrieve the开发者_如何学运维 ID of this new record of data

immediately after adding it into the database?


$this->Testing->id will contain the ID of the newly inserted record, but if you only need to know if the data was saved, you can check the return value of save(), which is false on failure.

0

精彩评论

暂无评论...
验证码 换一张
取 消