本文整理匯總了PHP中DatabaseConnection::lastID方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseConnection::lastID方法的具體用法?PHP DatabaseConnection::lastID怎麽用?PHP DatabaseConnection::lastID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::lastID方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testLastID
public function testLastID()
{
require __DIR__ . '/config/database_test.php';
$db = new DatabaseConnection($host, $database, $user, $password);
$insert_result = $db->query("INSERT INTO characters (id, name, description, type, dead, stage, hp) \r\n\t\t\tVALUES ('9999', 'Carla', 'The swordmaster of Melee Island', 'pirate', 'false', '4', '87');");
$actual = $db->lastID();
$expected = '9999';
$delete_result = $db->query("DELETE FROM characters WHERE id = '9999'");
$this->assertNotEmpty($actual, 'Function LastID returning empty value. Check TestDatabaseConnection::lastID()');
$this->assertEquals($expected, $actual, 'Function LastID not returning expected value. Check TestDatabaseConnection::lastID()');
}
示例2: lastID
/**
* Get the ID of the last row inserted
*
* @throws StatusCodeException if was not success
*
* @param DatabaseConnection database class instance
* @return string returns the id of the last row inserted
*/
public static function lastID(DatabaseConnection $db)
{
return $db->lastID();
}