开发者

Joomla syntax for mysql last inserted id?

Wh开发者_JAVA技巧at is the joomla syntax for mysql last inserted id?


It's just $db->insertid(); Ensure you call it immediately after the insert statement.


Get db connection

$db = JFactory::getDBO();

Create a new query object.

$query = $db->getQuery(true);

Query to insert data

$query->insert('tablename')->columns('columnname')->values('custom msg');

Reset the query using newly populated query object.

$db->setQuery($query);

Execute the query

$db->execute();
$lastinsertid = $db->insertid(); // last insert id 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜