DboSource::resetSequence PHP Method

resetSequence() public method

This method should be implemented by datasources that require sequences to be used.
public resetSequence ( string $table, string $column ) : boolean | void
$table string The name of the table to update.
$column string The column to use when resetting the sequence value.
return boolean | void success.
    public function resetSequence($table, $column)
    {
    }

Usage Example

 public function testResetSequence()
 {
     $model = new Article();
     $table = $this->Dbo->fullTableName($model, false);
     $fields = array('id', 'user_id', 'title', 'body', 'published');
     $values = array(array(1, 1, 'test', 'first post', false), array(2, 1, 'test 2', 'second post post', false));
     $this->Dbo->insertMulti($table, $fields, $values);
     $sequence = $this->Dbo->getSequence($table);
     $result = $this->Dbo->rawQuery("SELECT nextval('{$sequence}')");
     $original = $result->fetch(PDO::FETCH_ASSOC);
     $this->assertTrue($this->Dbo->resetSequence($table, 'id'));
     $result = $this->Dbo->rawQuery("SELECT currval('{$sequence}')");
     $new = $result->fetch(PDO::FETCH_ASSOC);
     $this->assertTrue($new['currval'] > $original['nextval'], 'Sequence did not update');
 }
All Usage Examples Of DboSource::resetSequence
DboSource