Skip to content

Commit 7040c3a

Browse files
committed
#26 - Add table_schema to WHERE clause
1 parent 0bd912a commit 7040c3a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/TgDatabase/Database.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,9 @@ public function updateSingle($table, $fields, $where) {
380380
* @return int - next auto increment value as UID.
381381
*/
382382
public function getNextUid($tableName) {
383-
$sql = 'SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name='.$this->quote($this->replaceTablePrefix($tableName));
383+
$sql = 'SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES '.
384+
'WHERE (table_schema='.$this->quote($this->replaceTablePrefix($this->config['dbname'])).') AND '.
385+
'(table_name='.$this->quote($this->replaceTablePrefix($tableName)).')';
384386
$record = $this->querySingle($sql);
385387
if (is_object($record)) return $record->auto_increment;
386388
return 0;

0 commit comments

Comments
 (0)