/**
  * Get the highest revision number applied for the given changeset name.
  *
  * @param string $changesetName
  * @return int
  */
 public function getCurrentRevisionForChangeset($changesetName)
 {
     if (!$this->tableExists()) {
         $this->createTable();
     }
     return (int) $this->dbAdapter->fetchOne(sprintf('SELECT MAX(change_number) FROM %s WHERE delta_set = ?', $this->dbAdapter->quoteIdentifier($this->tableName)), array($changesetName));
 }
Exemple #2
0
 public function testUpdateSuccessfullySavesExistingRowAndReturnsRowsAffected()
 {
     $affected = $this->table->update(array('name' => 'Star Fruit', 'is_delicious' => 1, 'level_of_deliciousness' => 4), 'dewdrop_test_fruit_id = 1');
     $this->assertEquals(1, $affected);
     $this->assertEquals(5, $this->db->fetchOne('SELECT COUNT(*) FROM dewdrop_test_fruits'));
     $this->assertEquals('Star Fruit', $this->db->fetchOne('SELECT name FROM dewdrop_test_fruits WHERE dewdrop_test_fruit_id = 1'));
 }
Exemple #3
0
 public function testSavingAnExistingRowPerformsAnUpdate()
 {
     $row = $this->table->find(1);
     $row->name = 'Grape';
     $row->save();
     $this->assertEquals(5, $this->db->fetchOne('SELECT COUNT(*) FROM dewdrop_test_fruits'));
     $this->assertEquals(1, $row->get('dewdrop_test_fruit_id'));
 }
Exemple #4
0
 /**
  * @expectedException \Dewdrop\Exception
  */
 public function testBadFetchOneThrowsException()
 {
     $this->db->fetchOne('not even close to valid sql');
 }
Exemple #5
0
 /**
  * Use MySQL's FOUND_ROWS() facility to retrieve the total number of rows
  * that would have been fetched on the previous statement if no LIMIT was
  * applied.
  *
  * @param array $resultSet
  * @return integer
  */
 public function fetchTotalRowCount(array $resultSet)
 {
     return $this->adapter->fetchOne('SELECT FOUND_ROWS()');
 }