<?php
abstract class DbConnection
{
protected $link;
protected $result;
protected $numRows;
abstract public function query($q);
abstract public function next();
abstract public function getLastId();
abstract public function closeConnection();
abstract public function cloneConnection();
abstract public function escape($string, $quoted = true);
abstract public function startTransaction();
abstract public function commit();
abstract public function rollBack();
public function getLink() {
return $this->link;
}
public function getRowsNum() {
return $this->numRows;
}
public function queryFirstRowCol($q) {
$row = $this->queryFirstRow($q);
return current($row);
}
public function queryFirstColumnSet($q) {
$arr = array();
$this->query($q);
while($row = $this->next())
$arr[] = current($row);
return $arr;
}
public function queryResultArr($q) {
$arr = array();
$this->query($q);
while($row = $this->next())
$arr[] = $row;
return $arr;
}
public function queryFirstRow($q) {
$this->query($q);
$row = $this->next();
if(!$row) throw new NoResultException($q);
return $row;
}
}
?>