yii/db/CDbCommand.php:
Код: Выделить всё
/**
* Builds and executes a SQL statement for truncating a DB table.
* @param string $table the table to be truncated. The name will be properly quoted by the method.
* @return integer number of rows affected by the execution.
* @since 1.1.6
*/
public function truncateTable($table)
{
$schema=$this->getConnection()->getSchema();
$n=$this->setText($schema->truncateTable($table))->execute();
if(strncasecmp($this->getConnection()->getDriverName(),'sqlite',6)===0)
$schema->resetSequence($table);
return $n;
}
yii/db/schema/sqlite/CSqliteSchema.php
Код: Выделить всё
/**
* Resets the sequence value of a table's primary key.
* The sequence will be reset such that the primary key of the next new row inserted
* will have the specified value or 1.
* @param CDbTableSchema $table the table schema whose primary key sequence will be reset
* @param mixed $value the value for the primary key of the next new row inserted. If this is not set,
* the next new row's primary key will have a value 1.
* @since 1.1
*/
public function resetSequence($table,$value=null)
{
if($table->sequenceName!==null)
{
if($value===null)
$value=$this->getDbConnection()->createCommand("SELECT MAX(`{$table->primaryKey}`) FROM {$table->rawName}")->queryScalar();
else
$value=(int)$value-1;
$this->getDbConnection()->createCommand("UPDATE sqlite_sequence SET seq='$value' WHERE name='{$table->name}'")->execute();
}
}
Видимо, имелось в виду
Код: Выделить всё
--- /var/www/yii/db/CDbCommand.php (revision 2937)
+++ /var/www/yii/db/CDbCommand.php (working copy)
@@ -1204,7 +1204,7 @@
$schema=$this->getConnection()->getSchema();
$n=$this->setText($schema->truncateTable($table))->execute();
if(strncasecmp($this->getConnection()->getDriverName(),'sqlite',6)===0)
- $schema->resetSequence($table);
+ $schema->resetSequence($schema->getTable($table));
return $n;
}