diff --git a/src/Database.php b/src/Database.php index 2e9a007..7a224c1 100644 --- a/src/Database.php +++ b/src/Database.php @@ -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 *