lastAffected() public method

Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
public lastAffected ( mixed $source = null ) : integer
$source mixed The source to check.
return integer Number of affected rows
 /**
  * testLastAffected method
  *
  *
  * @return void
  */
 public function testLastAffected()
 {
     $this->Dbo->cacheSources = false;
     $tableName = 'tinyint_' . uniqid();
     $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
     $this->model = new CakeTestModel(array('name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test'));
     $this->assertTrue((bool) $this->model->save(array('bool' => 5, 'small_int' => 5)));
     $this->assertEquals(1, $this->model->find('count'));
     $this->model->deleteAll(true);
     $result = $this->Dbo->lastAffected();
     $this->assertEquals(1, $result);
     $this->assertEquals(0, $this->model->find('count'));
     $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
 }
 /**
  * Returns number of affected rows in previous database operation. If no previous operation exists,
  * this returns false.
  *
  * @param mixed $source
  * @return integer Number of affected rows
  */
 public function lastAffected($source = null)
 {
     $affected = parent::lastAffected();
     if ($affected === null && $this->_lastAffected !== false) {
         return $this->_lastAffected;
     }
     return $affected;
 }
Example #3
0
 /**
  * Returns number of affected rows in previous database operation. If no previous operation exists,
  * this returns false.
  *
  * @param mixed $source Unused
  *
  * @return int Number of affected rows
  */
 public function lastAffected($source = NULL)
 {
     $affected = parent::lastAffected();
     if ($affected === NULL && $this->_lastAffected !== FALSE) {
         return $this->_lastAffected;
     }
     return $affected;
 }