2012-06-05 41 views

回答

1

試試這個..

其對於MySQL ..

LAST_INSERT_ID() 

OR

它對於PHP ..

mysql_insert_id() 

All the last_insert_id functions (be they PHP wrappers or the native mySQL one) typically refer to the last ID created using the current database connection. The last login was probably not created during the same request you are showing the table in, so this method won't work for you. 

Use a normal SELECT to find out the newest login instead - e.g. by using ORDER by creationtime DESC LIMIT 1. 

OR 在易我可以找到最後插入的ID這樣的..

Yii::app()->db->getLastInsertID(); 

也可以參考這個鏈接..

http://www.yiiframework.com/doc/api/1.0/CActiveRecord#primaryKey-detail