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:
@@ -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';
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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) . "'"
|
||||
|
@@ -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) . "'"
|
||||
|
@@ -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"); }
|
||||
/**#@-*/
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
* }
|
||||
* </code>
|
||||
*/
|
||||
class DibiResultIterator implements Iterator
|
||||
final class DibiResultIterator implements Iterator
|
||||
{
|
||||
private
|
||||
$result,
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user