开发者

Joomla syntax for mysql last inserted id?

开发者 https://www.devze.com 2022-12-26 17:56 出处:网络
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

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

精彩评论

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