MDL-17354 moved reset_sequence into dbmanager
This commit is contained in:
@@ -71,6 +71,22 @@ class sqlite_sql_generator extends sql_generator {
|
||||
parent::__construct($mdb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a sequence to the id field of a table.
|
||||
* @param string $table name of table
|
||||
* @return bool success
|
||||
*/
|
||||
public function reset_sequence($table) {
|
||||
if (is_string($table)) {
|
||||
$tablename = $table;
|
||||
} else {
|
||||
$tablename = $table->getName();
|
||||
}
|
||||
// From http://sqlite.org/autoinc.html
|
||||
$value = (int)$this->mdb->get_field_sql('SELECT MAX(id) FROM {'.$tablename.'}');
|
||||
return $this->mdb->change_database_structure("UPDATE sqlite_sequence SET seq=$value WHERE name='$this->prefix$tablename'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Given one correct xmldb_key, returns its specs
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user