1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 05:37:39 +02:00

* vetsina method/trid oznacena jako final

This commit is contained in:
David Grudl
2007-08-09 03:31:34 +00:00
parent 609a3d64fb
commit 8b89eb3bd0
12 changed files with 68 additions and 38 deletions

View File

@@ -130,7 +130,7 @@ class dibi
* dibi::query() error mode * dibi::query() error mode
* @var bool * @var bool
*/ */
public static $throwExceptions = FALSE; public static $throwExceptions = TRUE;
/** /**
* Substitutions for identifiers * Substitutions for identifiers
@@ -155,7 +155,7 @@ class dibi
* @return DibiDriver * @return DibiDriver
* @throws DibiException * @throws DibiException
*/ */
public static function connect($config, $name=0) public static function connect($config, $name = 0)
{ {
// DSN string // DSN string
if (is_string($config)) if (is_string($config))
@@ -203,7 +203,7 @@ class dibi
* @return object DibiDriver object. * @return object DibiDriver object.
* @throws DibiException * @throws DibiException
*/ */
public static function getConnection($name=NULL) public static function getConnection($name = NULL)
{ {
if ($name === NULL) { if ($name === NULL) {
if (!self::$connection) if (!self::$connection)
@@ -320,6 +320,36 @@ class dibi
/**
* Begins a transaction - Monostate for DibiDriver::begin()
*/
public static function begin()
{
return self::getConnection()->begin();
}
/**
* Commits statements in a transaction - Monostate for DibiDriver::commit()
*/
public static function commit()
{
return self::getConnection()->commit();
}
/**
* Rollback changes in a transaction - Monostate for DibiDriver::rollback()
*/
public static function rollback()
{
return self::getConnection()->rollback();
}
private static function dumpHighlight($matches) private static function dumpHighlight($matches)
{ {
if (!empty($matches[1])) // comment if (!empty($matches[1])) // comment
@@ -344,7 +374,7 @@ class dibi
* @param bool return or print? * @param bool return or print?
* @return void * @return void
*/ */
public static function dump($sql, $return=FALSE) { public static function dump($sql, $return = FALSE) {
static $keywords2 = 'ALL|DISTINCT|AS|ON|INTO|AND|OR|AS'; static $keywords2 = 'ALL|DISTINCT|AS|ON|INTO|AND|OR|AS';
static $keywords1 = 'SELECT|UPDATE|INSERT|DELETE|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN'; static $keywords1 = 'SELECT|UPDATE|INSERT|DELETE|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN';

View File

@@ -132,7 +132,7 @@ class DibiMSSqlDriver extends DibiDriver
} }
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
$value = str_replace("'", "''", $value); $value = str_replace("'", "''", $value);
return $appendQuotes return $appendQuotes

View File

@@ -169,7 +169,7 @@ class DibiMySqlDriver extends DibiDriver
} }
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
$connection = $this->getConnection(); $connection = $this->getConnection();
return $appendQuotes return $appendQuotes

View File

@@ -149,7 +149,7 @@ class DibiMySqliDriver extends DibiDriver
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
$connection = $this->getConnection(); $connection = $this->getConnection();
return $appendQuotes return $appendQuotes

View File

@@ -149,7 +149,7 @@ class DibiOdbcDriver extends DibiDriver
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
$value = str_replace("'", "''", $value); $value = str_replace("'", "''", $value);
return $appendQuotes return $appendQuotes

View File

@@ -118,7 +118,7 @@ class DibiPdoDriver extends DibiDriver
} }
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
if (!$appendQuotes) { if (!$appendQuotes) {
trigger_error('dibi: escaping without qoutes is not supported by PDO', E_USER_WARNING); trigger_error('dibi: escaping without qoutes is not supported by PDO', E_USER_WARNING);

View File

@@ -135,7 +135,7 @@ class DibiPostgreDriver extends DibiDriver
} }
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
return $appendQuotes return $appendQuotes
? "'" . pg_escape_string($value) . "'" ? "'" . pg_escape_string($value) . "'"

View File

@@ -138,7 +138,7 @@ class DibiSqliteDriver extends DibiDriver
} }
public function escape($value, $appendQuotes=TRUE) public function escape($value, $appendQuotes = TRUE)
{ {
return $appendQuotes return $appendQuotes
? "'" . sqlite_escape_string($value) . "'" ? "'" . sqlite_escape_string($value) . "'"

View File

@@ -75,7 +75,7 @@ abstract class DibiDriver
* @see DibiDriver::__construct * @see DibiDriver::__construct
* @return array * @return array
*/ */
public function getConfig() final public function getConfig()
{ {
return $this->config; return $this->config;
} }
@@ -86,7 +86,7 @@ abstract class DibiDriver
* Returns the connection resource * Returns the connection resource
* @return resource * @return resource
*/ */
public function getConnection() final public function getConnection()
{ {
if (!$this->connection) $this->connection = $this->connect(); if (!$this->connection) $this->connection = $this->connect();
@@ -102,7 +102,7 @@ abstract class DibiDriver
* @return int|DibiResult * @return int|DibiResult
* @throws DibiException * @throws DibiException
*/ */
public function query($args) final public function query($args)
{ {
// receive arguments // receive arguments
if (!is_array($args)) if (!is_array($args))
@@ -219,7 +219,7 @@ abstract class DibiDriver
* @param bool quote string? * @param bool quote string?
* @return string escaped and optionally quoted string * @return string escaped and optionally quoted string
*/ */
abstract public function escape($value, $appendQuotes=TRUE); abstract public function escape($value, $appendQuotes = TRUE);
@@ -256,9 +256,9 @@ abstract class DibiDriver
* Access to undeclared property * Access to undeclared property
* @throws Exception * @throws Exception
*/ */
function __get($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __get($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
function __set($name, $value) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __set($name, $value) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
function __unset($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __unset($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
/**#@-*/ /**#@-*/

View File

@@ -28,7 +28,7 @@ class DibiException extends Exception
$dbError; $dbError;
public function __construct($message, $dbError=NULL, $sql=NULL) public function __construct($message, $dbError = NULL, $sql = NULL)
{ {
$this->dbError = $dbError; $this->dbError = $dbError;
$this->sql = $sql; $this->sql = $sql;
@@ -37,13 +37,13 @@ class DibiException extends Exception
} }
public function getSql() final public function getSql()
{ {
return $this->sql; return $this->sql;
} }
public function getDbError() final public function getDbError()
{ {
return $this->dbError; return $this->dbError;
} }

View File

@@ -244,7 +244,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
* @param string value * @param string value
* @return array * @return array
*/ */
final function fetchPairs($key=NULL, $value=NULL) final function fetchPairs($key = NULL, $value = NULL)
{ {
@$this->seek(0); @$this->seek(0);
$row = $this->fetch(); $row = $this->fetch();
@@ -294,7 +294,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
public function setType($field, $type = NULL) final public function setType($field, $type = NULL)
{ {
if ($field === TRUE) if ($field === TRUE)
$this->detectTypes(); $this->detectTypes();
@@ -309,14 +309,14 @@ abstract class DibiResult implements IteratorAggregate, Countable
/** is this needed? */ /** is this needed? */
public function getType($field) final public function getType($field)
{ {
return isset($this->convert[$field]) ? $this->convert[$field] : NULL; return isset($this->convert[$field]) ? $this->convert[$field] : NULL;
} }
public function convert($value, $type) final public function convert($value, $type)
{ {
if ($value === NULL || $value === FALSE) if ($value === NULL || $value === FALSE)
return $value; return $value;
@@ -341,7 +341,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
* Gets an array of field names * Gets an array of field names
* @return array * @return array
*/ */
public function getFields() final public function getFields()
{ {
// lazy init // lazy init
if ($this->meta === NULL) $this->buildMeta(); if ($this->meta === NULL) $this->buildMeta();
@@ -355,7 +355,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
* @param string column name * @param string column name
* @return array * @return array
*/ */
public function getMetaData($field) final public function getMetaData($field)
{ {
// lazy init // lazy init
if ($this->meta === NULL) $this->buildMeta(); if ($this->meta === NULL) $this->buildMeta();
@@ -368,7 +368,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
* Acquires .... * Acquires ....
* @return void * @return void
*/ */
protected function detectTypes() final protected function detectTypes()
{ {
if ($this->meta === NULL) $this->buildMeta(); if ($this->meta === NULL) $this->buildMeta();
} }
@@ -383,7 +383,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
/** these are the required IteratorAggregate functions */ /** these are the required IteratorAggregate functions */
public function getIterator($offset = NULL, $count = NULL) final public function getIterator($offset = NULL, $count = NULL)
{ {
return new DibiResultIterator($this, $offset, $count); return new DibiResultIterator($this, $offset, $count);
} }
@@ -392,7 +392,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
/** these are the required Countable functions */ /** these are the required Countable functions */
public function count() final public function count()
{ {
return $this->rowCount(); return $this->rowCount();
} }
@@ -404,9 +404,9 @@ abstract class DibiResult implements IteratorAggregate, Countable
* Access to undeclared property * Access to undeclared property
* @throws Exception * @throws Exception
*/ */
function __get($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __get($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
function __set($name, $value) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __set($name, $value) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
function __unset($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __unset($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
/**#@-*/ /**#@-*/
} // class DibiResult } // class DibiResult
@@ -437,7 +437,7 @@ abstract class DibiResult implements IteratorAggregate, Countable
* } * }
* </code> * </code>
*/ */
class DibiResultIterator implements Iterator final class DibiResultIterator implements Iterator
{ {
private private
$result, $result,

View File

@@ -21,7 +21,7 @@ if (!class_exists('dibi', FALSE)) die();
* dibi translator * dibi translator
* *
*/ */
class DibiTranslator final class DibiTranslator
{ {
private private
$driver, $driver,
@@ -381,9 +381,9 @@ class DibiTranslator
* Access to undeclared property * Access to undeclared property
* @throws Exception * @throws Exception
*/ */
function __get($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __get($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
function __set($name, $value) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __set($name, $value) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
function __unset($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); } final function __unset($name) { throw new Exception("Access to undeclared property: " . get_class($this) . "::$$name"); }
/**#@-*/ /**#@-*/
} // class DibiParser } // class DibiParser