*/
public abstract function _errorString();
+ // ###################################################################
+ /**
+ * Fetch the unique ID of the record just inserted
+ *
+ * @return integer Insert-ID
+ */
+ public function insertId()
+ {
+ return $this->_insertID();
+ }
+
+ /**
+ * Abstract function that returns the ID of the most recently-inserted
+ * record
+ *
+ * @return integer Insertion ID
+ */
+ protected abstract function _insertId();
+
+ // ###################################################################
+ /**
+ * Fetch the number of rows affected by the query
+ *
+ * @param integer Result
+ *
+ * @return integer Number of affected rows
+ */
+ public function affectedRows()
+ {
+ return $this->_affectedRows($this->result);
+ }
+
+ /**
+ * Abstract function that returns the number of affected rows in the result
+ *
+ * @param integer Result ID
+ *
+ * @return integer Number of rows
+ */
+ protected abstract function _affectedRows($result);
+
// ###################################################################
/**
* Sends the command to start a transaction. This command should never
*/
public function free()
{
- $this->_freeResult($result);
+ $this->_freeResult($this->result);
}
/**
*/
protected abstract function _freeResult($result);
- // ###################################################################
- /**
- * Fetch the unique ID of the record just inserted
- *
- * @return integer Insert-ID
- */
- public function insertId()
- {
- return $this->_insertID();
- }
-
- /**
- * Abstract function that returns the ID of the most recently-inserted
- * record
- *
- * @return integer Insertion ID
- */
- protected abstract function _insertId();
-
// ###################################################################
/**
* Fetch the number of rows in the result
* @return integer Number of rows
*/
protected abstract function _numRows($result);
-
- // ###################################################################
- /**
- * Fetch the number of rows affected by the query
- *
- * @param integer Result
- *
- * @return integer Number of affected rows
- */
- public function affectedRows()
- {
- return $this->_affectedRows($this->result);
- }
-
- /**
- * Abstract function that returns the number of affected rows in the result
- *
- * @param integer Result ID
- *
- * @return integer Number of rows
- */
- protected abstract function _affectedRows($result);
}
/**
return $string;
}
+ // ###################################################################
+ /**
+ * Wrapper: mysql_insert_id
+ */
+ protected function _insertId()
+ {
+ return mysql_insert_id($this->dblink);
+ }
+
+ // ###################################################################
+ /**
+ * Wrapper: mysql_affected_rows
+ */
+ protected function _affectedRows($result)
+ {
+ return mysql_affected_rows($this->dblink);
+ }
+
// ###################################################################
/**
* Starts a database transaction
mysql_free_result($result);
}
- // ###################################################################
- /**
- * Wrapper: mysql_insert_id
- */
- protected function _insertId()
- {
- return mysql_insert_id($this->dblink);
- }
-
// ###################################################################
/**
* Wrapper: mysql_num_rows
{
return mysql_num_rows($result);
}
-
- // ###################################################################
- /**
- * Wrapper: mysql_affected_rows
- */
- protected function _affectedRows($result)
- {
- return mysql_affected_rows($this->dblink);
- }
}
?>
\ No newline at end of file
return $string;
}
+ // ###################################################################
+ /**
+ * Wrapper: mysql_insert_id
+ */
+ protected function _insertId()
+ {
+ return mysqli_insert_id($this->dblink);
+ }
+
+ // ###################################################################
+ /**
+ * Wrapper: mysql_affected_rows
+ */
+ protected function _affectedRows($result)
+ {
+ return mysqli_affected_rows($this->dblink);
+ }
+
// ###################################################################
/**
* Starts a database transaction
mysqli_free_result($result);
}
- // ###################################################################
- /**
- * Wrapper: mysql_insert_id
- */
- protected function _insertId()
- {
- return mysqli_insert_id($this->dblink);
- }
-
// ###################################################################
/**
* Wrapper: mysql_num_rows
{
return mysqli_num_rows($result);
}
-
- // ###################################################################
- /**
- * Wrapper: mysql_affected_rows
- */
- protected function _affectedRows($result)
- {
- return mysqli_affected_rows($this->dblink);
- }
}
?>
\ No newline at end of file
return -1;
}
+ // ###################################################################
+ /**
+ * Overload: insertId
+ */
+ public function insertId($table, $field)
+ {
+ return $this->queryFirst("SELECT last_value FROM {$table}_{$field}_seq")->fetchObject()->last_value;
+ }
+
+ protected function _insertId()
+ {}
+
+ // ###################################################################
+ /**
+ * Wrapper: pg_affected_rows
+ */
+ protected function _affectedRows($result)
+ {
+ return pg_affected_rows($result);
+ }
+
// ###################################################################
/**
* Starts a database transaction
*/
- public function start()
+ public function begin()
{
$this->query("BEGIN");
}
*
*/
class BSDbPostgreSqlResult extends BSDbResult
-{
- // ###################################################################
- /**
- * Overload: insertId
- */
- public function insertId($table, $field)
- {
- return $this->queryFirst("SELECT last_value FROM {$table}_{$field}_seq")->fetchObject()->last_value;
- }
-
- protected function _insertId()
- {}
-
+{
// ###################################################################
/**
* Wrapper: pg_fetch_assoc
{
return pg_num_rows($result);
}
-
- // ###################################################################
- /**
- * Wrapper: pg_affected_rows
- */
- protected function _affectedRows($result)
- {
- return pg_affected_rows($result);
- }
}
?>
\ No newline at end of file
$this->fixture->query("INSERT INTO test (textstuff) VALUES ('123'), ('456'), ('789')");
$res = $this->fixture->query("SELECT * FROM test");
- $this->assertEquals(3, $res->numRows());
+ $this->assertEquals(3, $res->size());
$res = $this->fixture->query("SELECT * FROM test WHERE textstuff = '--invalid value--'");
- $this->assertEquals(0, $res->numRows());
+ $this->assertEquals(0, $res->size());
}
catch (BSDbException $e)
{
$this->fixture->query("INSERT INTO test (textstuff) VALUES ('123'), ('456'), ('123')");
$res = $this->fixture->query("UPDATE test SET textstuff = 'abc' WHERE textstuff = '123'");
- $this->assertEquals(2, $res->affectedRows());
+ $this->assertEquals(2, $this->fixture->affectedRows());
$res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'abc'");
- $this->assertEquals(2, $res->numRows());
+ $this->assertEquals(2, $res->size());
}
catch (BSDbException $e)
{
$this->fixture->commit();
$res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'foo'");
- $this->assertEquals(1, $res->numRows());
+ $this->assertEquals(1, $res->size());
$this->fixture->begin();
$this->fixture->query("UPDATE test SET textstuff = 'abc'");
$this->fixture->rollback();
$res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'abc'");
- $this->assertEquals(0, $res->numRows());
+ $this->assertEquals(0, $res->size());
$res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'foo'");
- $this->assertEquals(1, $res->numRows());
+ $this->assertEquals(1, $res->size());
}
}