feat: add method for querying the current AUTO_INCREMENT for a table

This commit is contained in:
Victor Westerlund 2026-02-16 11:15:17 +01:00
parent b14c14d9b3
commit 873c1d592b
Signed by: vlw
GPG key ID: D0AD730E1057DFC6

View file

@ -76,6 +76,19 @@
parent::__construct(); parent::__construct();
} }
/**
* Return the current AUTO_INCREMENT value for a given table
*
* @param string $table
* @return int
*/
public function latest(string $table): int {
return $this->execute_query("SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?", [
self::$name,
self::get_table($table)
])->fetch_assoc()["AUTO_INCREMENT"];
}
/** /**
* Fetch and set the WordPress siteurl from the options table * Fetch and set the WordPress siteurl from the options table
* *