mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 13:17:58 +02:00
Driver's reflection capabilities moved to IDibiReflector
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
* @copyright Copyright (c) 2010
|
* @copyright Copyright (c) 2010
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiFirebirdDriver extends DibiObject implements IDibiDriver
|
class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
const ERROR_EXCEPTION_THROWN = -836;
|
const ERROR_EXCEPTION_THROWN = -836;
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ********************/
|
/********************* IDibiReflector ********************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -340,55 +340,4 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
|
|||||||
return $this->resultSet;
|
return $this->resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns list of tables.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTables()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all columns in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getColumns($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all indexes in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getIndexes($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all foreign keys in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getForeignKeys($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -341,55 +341,4 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
|
|||||||
return $this->resultSet;
|
return $this->resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns list of tables.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTables()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all columns in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getColumns($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all indexes in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getIndexes($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all foreign keys in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getForeignKeys($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiMySqlDriver extends DibiObject implements IDibiDriver
|
class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
const ERROR_ACCESS_DENIED = 1045;
|
const ERROR_ACCESS_DENIED = 1045;
|
||||||
const ERROR_DUPLICATE_ENTRY = 1062;
|
const ERROR_DUPLICATE_ENTRY = 1062;
|
||||||
@@ -426,7 +426,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiMySqliDriver extends DibiObject implements IDibiDriver
|
class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
const ERROR_ACCESS_DENIED = 1045;
|
const ERROR_ACCESS_DENIED = 1045;
|
||||||
const ERROR_DUPLICATE_ENTRY = 1062;
|
const ERROR_DUPLICATE_ENTRY = 1062;
|
||||||
@@ -418,7 +418,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
/** @var resource Connection resource */
|
/** @var resource Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
@@ -368,7 +368,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiOracleDriver extends DibiObject implements IDibiDriver
|
class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
/** @var resource Connection resource */
|
/** @var resource Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
@@ -356,7 +356,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -423,55 +423,4 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
|
|||||||
return $this->resultSet;
|
return $this->resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns list of tables.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getTables()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all columns in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getColumns($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all indexes in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getIndexes($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns metadata for all foreign keys in a table.
|
|
||||||
* @param string
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getForeignKeys($table)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
/** @var resource Connection resource */
|
/** @var resource Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
@@ -388,7 +388,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiSqliteDriver extends DibiObject implements IDibiDriver
|
class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
/** @var resource Connection resource */
|
/** @var resource Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
@@ -377,7 +377,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
* @copyright Copyright (c) 2005, 2010 David Grudl
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
* @package dibi\drivers
|
* @package dibi\drivers
|
||||||
*/
|
*/
|
||||||
class DibiSqlite3Driver extends DibiObject implements IDibiDriver
|
class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiReflector
|
||||||
{
|
{
|
||||||
/** @var SQLite3 Connection resource */
|
/** @var SQLite3 Connection resource */
|
||||||
private $connection;
|
private $connection;
|
||||||
@@ -363,7 +363,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
/********************* IDibiReflector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ class DibiConnection extends DibiObject
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->driver = new $class;
|
$this->driver = new $class;
|
||||||
|
|
||||||
// profiler
|
// profiler
|
||||||
$profilerCfg = & $config['profiler'];
|
$profilerCfg = & $config['profiler'];
|
||||||
if (is_numeric($profilerCfg) || is_bool($profilerCfg)) { // back compatibility
|
if (is_numeric($profilerCfg) || is_bool($profilerCfg)) { // back compatibility
|
||||||
$profilerCfg = array('run' => (bool) $profilerCfg);
|
$profilerCfg = array('run' => (bool) $profilerCfg);
|
||||||
@@ -717,6 +717,9 @@ class DibiConnection extends DibiObject
|
|||||||
*/
|
*/
|
||||||
public function getDatabaseInfo()
|
public function getDatabaseInfo()
|
||||||
{
|
{
|
||||||
|
if (!($this->driver instanceof IDibiReflector)) {
|
||||||
|
throw new NotSupportedException('Driver '. get_class($this->driver) . ' has not reflection capabilities.');
|
||||||
|
}
|
||||||
$this->connect();
|
$this->connect();
|
||||||
return new DibiDatabaseInfo($this->driver, isset($this->config['database']) ? $this->config['database'] : NULL);
|
return new DibiDatabaseInfo($this->driver, isset($this->config['database']) ? $this->config['database'] : NULL);
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
class DibiDatabaseInfo extends DibiObject
|
class DibiDatabaseInfo extends DibiObject
|
||||||
{
|
{
|
||||||
/** @var IDibiDriver */
|
/** @var IDibiReflector */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -35,7 +35,7 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver, $name)
|
public function __construct(IDibiReflector $driver, $name)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@@ -145,7 +145,7 @@ class DibiDatabaseInfo extends DibiObject
|
|||||||
*/
|
*/
|
||||||
class DibiTableInfo extends DibiObject
|
class DibiTableInfo extends DibiObject
|
||||||
{
|
{
|
||||||
/** @var IDibiDriver */
|
/** @var IDibiReflector */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -168,7 +168,7 @@ class DibiTableInfo extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver, array $info)
|
public function __construct(IDibiReflector $driver, array $info)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
$this->name = $info['name'];
|
$this->name = $info['name'];
|
||||||
@@ -349,7 +349,7 @@ class DibiTableInfo extends DibiObject
|
|||||||
*/
|
*/
|
||||||
class DibiResultInfo extends DibiObject
|
class DibiResultInfo extends DibiObject
|
||||||
{
|
{
|
||||||
/** @var IDibiDriver */
|
/** @var IDibiReflector */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
@@ -360,7 +360,7 @@ class DibiResultInfo extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver)
|
public function __construct(IDibiReflector $driver)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
}
|
}
|
||||||
@@ -466,7 +466,7 @@ class DibiColumnInfo extends DibiObject
|
|||||||
/** @var array */
|
/** @var array */
|
||||||
private static $types;
|
private static $types;
|
||||||
|
|
||||||
/** @var IDibiDriver */
|
/** @var IDibiReflector */
|
||||||
private $driver;
|
private $driver;
|
||||||
|
|
||||||
/** @var array (name, nativetype, [table], [fullname], [size], [nullable], [default], [autoincrement], [vendor]) */
|
/** @var array (name, nativetype, [table], [fullname], [size], [nullable], [default], [autoincrement], [vendor]) */
|
||||||
@@ -477,7 +477,7 @@ class DibiColumnInfo extends DibiObject
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(IDibiDriver $driver, array $info)
|
public function __construct(IDibiReflector $driver, array $info)
|
||||||
{
|
{
|
||||||
$this->driver = $driver;
|
$this->driver = $driver;
|
||||||
$this->info = $info;
|
$this->info = $info;
|
||||||
|
@@ -127,7 +127,7 @@ class DibiFluent extends DibiObject implements IDataSource
|
|||||||
$this->command = $clause;
|
$this->command = $clause;
|
||||||
}
|
}
|
||||||
|
|
||||||
// auto-switch to a clause
|
// auto-switch to a clause
|
||||||
if (isset(self::$clauseSwitches[$clause])) {
|
if (isset(self::$clauseSwitches[$clause])) {
|
||||||
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
|
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
|
||||||
}
|
}
|
||||||
|
@@ -231,12 +231,20 @@ interface IDibiDriver
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function getResultResource();
|
function getResultResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* reflection ****************d*g**/
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dibi driver reflection.
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2005, 2010 David Grudl
|
||||||
|
* @package dibi
|
||||||
|
*/
|
||||||
|
interface IDibiReflector
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of tables.
|
* Returns list of tables.
|
||||||
|
Reference in New Issue
Block a user