MDL-17354 moved reset_sequence into dbmanager

This commit is contained in:
skodak
2008-11-21 21:40:50 +00:00
parent 3eae57b74e
commit be415e95be
18 changed files with 158 additions and 158 deletions
+16
View File
@@ -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
*/