rithy
(Ph Ri Kh)
January 27, 2013, 8:20am
1
Hi Everyone,
I have a problem with Yii Framework.
public function doRestCreate($data)
{
$model = $this->getModel();
$ids = $this->saveModel($model, $data);
$this->renderJson($ids);
}
I can return this model(ID =0, Name = Test) my ID Field in database is auto increment, so I want to get create object include ID (get from ID field auto increment).
Please help me to create it.
yugenekr
(Yugenekr)
January 28, 2013, 9:37am
2
Hi rith thy,
I didn’t understand in details what’s your exact problem according to the code provided. But in common, when you save the model, ID is available right after that as usual, $model->id. In addition, you may use [url="http://www.yiiframework.com/doc/api/1.1/CDbConnection#getLastInsertID-detail" ]getLastInsertID/url
Hope this will help.
tri
(tri - Tommy Riboe)
February 8, 2013, 10:13pm
3
/* moved to General Discussion */
(not a tip, snippet or tutorial)