mirror of
https://codeberg.org/vlw/wp.git
synced 2026-02-26 03:51:58 +01:00
feat: add method for querying the current AUTO_INCREMENT for a table (#5)
This will be used to retrieve the primary key for newly inserted rows. Reviewed-on: https://codeberg.org/vlw/wp/pulls/5
This commit is contained in:
parent
28f31250fa
commit
fa4147e7ab
1 changed files with 13 additions and 0 deletions
|
|
@ -76,6 +76,19 @@
|
|||
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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue