From 8b89eb3bd09ca1a58fb2b6aaa9b9aa33a827f997 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 9 Aug 2007 03:31:34 +0000 Subject: [PATCH] * vetsina method/trid oznacena jako final --- dibi/dibi.php | 38 ++++++++++++++++++++++++++++++++++---- dibi/drivers/mssql.php | 2 +- dibi/drivers/mysql.php | 2 +- dibi/drivers/mysqli.php | 2 +- dibi/drivers/odbc.php | 2 +- dibi/drivers/pdo.php | 2 +- dibi/drivers/postgre.php | 2 +- dibi/drivers/sqlite.php | 2 +- dibi/libs/driver.php | 14 +++++++------- dibi/libs/exception.php | 6 +++--- dibi/libs/resultset.php | 26 +++++++++++++------------- dibi/libs/translator.php | 8 ++++---- 12 files changed, 68 insertions(+), 38 deletions(-) diff --git a/dibi/dibi.php b/dibi/dibi.php index 7de19316..cd49267e 100644 --- a/dibi/dibi.php +++ b/dibi/dibi.php @@ -130,7 +130,7 @@ class dibi * dibi::query() error mode * @var bool */ - public static $throwExceptions = FALSE; + public static $throwExceptions = TRUE; /** * Substitutions for identifiers @@ -155,7 +155,7 @@ class dibi * @return DibiDriver * @throws DibiException */ - public static function connect($config, $name=0) + public static function connect($config, $name = 0) { // DSN string if (is_string($config)) @@ -203,7 +203,7 @@ class dibi * @return object DibiDriver object. * @throws DibiException */ - public static function getConnection($name=NULL) + public static function getConnection($name = NULL) { if ($name === NULL) { 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) { if (!empty($matches[1])) // comment @@ -344,7 +374,7 @@ class dibi * @param bool return or print? * @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 $keywords1 = 'SELECT|UPDATE|INSERT|DELETE|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN'; diff --git a/dibi/drivers/mssql.php b/dibi/drivers/mssql.php index 95cf7e60..b9c14951 100644 --- a/dibi/drivers/mssql.php +++ b/dibi/drivers/mssql.php @@ -132,7 +132,7 @@ class DibiMSSqlDriver extends DibiDriver } - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { $value = str_replace("'", "''", $value); return $appendQuotes diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index 6cd3bd18..4e0c67f5 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -169,7 +169,7 @@ class DibiMySqlDriver extends DibiDriver } - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { $connection = $this->getConnection(); return $appendQuotes diff --git a/dibi/drivers/mysqli.php b/dibi/drivers/mysqli.php index ccf9110f..48311497 100644 --- a/dibi/drivers/mysqli.php +++ b/dibi/drivers/mysqli.php @@ -149,7 +149,7 @@ class DibiMySqliDriver extends DibiDriver - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { $connection = $this->getConnection(); return $appendQuotes diff --git a/dibi/drivers/odbc.php b/dibi/drivers/odbc.php index a3bb1fac..32e46543 100644 --- a/dibi/drivers/odbc.php +++ b/dibi/drivers/odbc.php @@ -149,7 +149,7 @@ class DibiOdbcDriver extends DibiDriver - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { $value = str_replace("'", "''", $value); return $appendQuotes diff --git a/dibi/drivers/pdo.php b/dibi/drivers/pdo.php index c6898633..5818f7c8 100644 --- a/dibi/drivers/pdo.php +++ b/dibi/drivers/pdo.php @@ -118,7 +118,7 @@ class DibiPdoDriver extends DibiDriver } - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { if (!$appendQuotes) { trigger_error('dibi: escaping without qoutes is not supported by PDO', E_USER_WARNING); diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index cc0c5bc9..22258614 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -135,7 +135,7 @@ class DibiPostgreDriver extends DibiDriver } - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { return $appendQuotes ? "'" . pg_escape_string($value) . "'" diff --git a/dibi/drivers/sqlite.php b/dibi/drivers/sqlite.php index 7f3b613a..f6078d29 100644 --- a/dibi/drivers/sqlite.php +++ b/dibi/drivers/sqlite.php @@ -138,7 +138,7 @@ class DibiSqliteDriver extends DibiDriver } - public function escape($value, $appendQuotes=TRUE) + public function escape($value, $appendQuotes = TRUE) { return $appendQuotes ? "'" . sqlite_escape_string($value) . "'" diff --git a/dibi/libs/driver.php b/dibi/libs/driver.php index 88d843cb..d4e83f99 100644 --- a/dibi/libs/driver.php +++ b/dibi/libs/driver.php @@ -75,7 +75,7 @@ abstract class DibiDriver * @see DibiDriver::__construct * @return array */ - public function getConfig() + final public function getConfig() { return $this->config; } @@ -86,7 +86,7 @@ abstract class DibiDriver * Returns the connection resource * @return resource */ - public function getConnection() + final public function getConnection() { if (!$this->connection) $this->connection = $this->connect(); @@ -102,7 +102,7 @@ abstract class DibiDriver * @return int|DibiResult * @throws DibiException */ - public function query($args) + final public function query($args) { // receive arguments if (!is_array($args)) @@ -219,7 +219,7 @@ abstract class DibiDriver * @param bool quote 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 * @throws Exception */ - 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"); } - function __unset($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"); } + final function __set($name, $value) { 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"); } /**#@-*/ diff --git a/dibi/libs/exception.php b/dibi/libs/exception.php index 30c43d07..0f3aaa7f 100644 --- a/dibi/libs/exception.php +++ b/dibi/libs/exception.php @@ -28,7 +28,7 @@ class DibiException extends Exception $dbError; - public function __construct($message, $dbError=NULL, $sql=NULL) + public function __construct($message, $dbError = NULL, $sql = NULL) { $this->dbError = $dbError; $this->sql = $sql; @@ -37,13 +37,13 @@ class DibiException extends Exception } - public function getSql() + final public function getSql() { return $this->sql; } - public function getDbError() + final public function getDbError() { return $this->dbError; } diff --git a/dibi/libs/resultset.php b/dibi/libs/resultset.php index 8dec2051..f11e7984 100644 --- a/dibi/libs/resultset.php +++ b/dibi/libs/resultset.php @@ -244,7 +244,7 @@ abstract class DibiResult implements IteratorAggregate, Countable * @param string value * @return array */ - final function fetchPairs($key=NULL, $value=NULL) + final function fetchPairs($key = NULL, $value = NULL) { @$this->seek(0); $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) $this->detectTypes(); @@ -309,14 +309,14 @@ abstract class DibiResult implements IteratorAggregate, Countable /** is this needed? */ - public function getType($field) + final public function getType($field) { 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) return $value; @@ -341,7 +341,7 @@ abstract class DibiResult implements IteratorAggregate, Countable * Gets an array of field names * @return array */ - public function getFields() + final public function getFields() { // lazy init if ($this->meta === NULL) $this->buildMeta(); @@ -355,7 +355,7 @@ abstract class DibiResult implements IteratorAggregate, Countable * @param string column name * @return array */ - public function getMetaData($field) + final public function getMetaData($field) { // lazy init if ($this->meta === NULL) $this->buildMeta(); @@ -368,7 +368,7 @@ abstract class DibiResult implements IteratorAggregate, Countable * Acquires .... * @return void */ - protected function detectTypes() + final protected function detectTypes() { if ($this->meta === NULL) $this->buildMeta(); } @@ -383,7 +383,7 @@ abstract class DibiResult implements IteratorAggregate, Countable /** 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); } @@ -392,7 +392,7 @@ abstract class DibiResult implements IteratorAggregate, Countable /** these are the required Countable functions */ - public function count() + final public function count() { return $this->rowCount(); } @@ -404,9 +404,9 @@ abstract class DibiResult implements IteratorAggregate, Countable * Access to undeclared property * @throws Exception */ - 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"); } - function __unset($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"); } + final function __set($name, $value) { 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 @@ -437,7 +437,7 @@ abstract class DibiResult implements IteratorAggregate, Countable * } * */ -class DibiResultIterator implements Iterator +final class DibiResultIterator implements Iterator { private $result, diff --git a/dibi/libs/translator.php b/dibi/libs/translator.php index 3c88e187..063db191 100644 --- a/dibi/libs/translator.php +++ b/dibi/libs/translator.php @@ -21,7 +21,7 @@ if (!class_exists('dibi', FALSE)) die(); * dibi translator * */ -class DibiTranslator +final class DibiTranslator { private $driver, @@ -381,9 +381,9 @@ class DibiTranslator * Access to undeclared property * @throws Exception */ - 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"); } - function __unset($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"); } + final function __set($name, $value) { 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