/** * 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)); }
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')); }
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')); }
/** * @expectedException \Dewdrop\Exception */ public function testBadFetchOneThrowsException() { $this->db->fetchOne('not even close to valid sql'); }
/** * 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()'); }