SQL generators must not execute changes in DB. Just provide the needed SQL

in order to make database_manager to execute it. reset_sequence reimplemented.
This commit is contained in:
stronk7
2009-08-31 14:23:40 +00:00
parent 576ace3245
commit b1ca138716
8 changed files with 57 additions and 48 deletions
+7 -7
View File
@@ -74,18 +74,18 @@ class sqlite_sql_generator extends sql_generator {
/**
* Reset a sequence to the id field of a table.
* @param string $table name of table
* @param string $table name of table or xmldb_object
* @return bool success
*/
public function reset_sequence($table) {
if (is_string($table)) {
$tablename = $table;
} else {
$tablename = $table->getName();
public function getResetSequenceSQL($table) {
if ($table instanceof xmldb_table) {
$table = $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'");
return array("UPDATE sqlite_sequence SET seq=$value WHERE name='$this->prefix$tablename'");
}
/**