1
0
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:
David Grudl
2010-05-26 16:26:21 +02:00
parent 7bac2ef3b3
commit 8c99f0c04d
15 changed files with 38 additions and 180 deletions

View File

@@ -27,7 +27,7 @@
* @copyright Copyright (c) 2010
* @package dibi\drivers
*/
class DibiFirebirdDriver extends DibiObject implements IDibiDriver
class DibiFirebirdDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
const ERROR_EXCEPTION_THROWN = -836;
@@ -400,7 +400,7 @@ class DibiFirebirdDriver extends DibiObject implements IDibiDriver
/********************* reflection ********************/
/********************* IDibiReflector ********************/

View File

@@ -340,55 +340,4 @@ class DibiMsSqlDriver extends DibiObject implements IDibiDriver
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;
}
}

View File

@@ -341,55 +341,4 @@ class DibiMsSql2005Driver extends DibiObject implements IDibiDriver
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;
}
}

View File

@@ -32,7 +32,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiMySqlDriver extends DibiObject implements IDibiDriver
class DibiMySqlDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
const ERROR_ACCESS_DENIED = 1045;
const ERROR_DUPLICATE_ENTRY = 1062;
@@ -426,7 +426,7 @@ class DibiMySqlDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -32,7 +32,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiMySqliDriver extends DibiObject implements IDibiDriver
class DibiMySqliDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
const ERROR_ACCESS_DENIED = 1045;
const ERROR_DUPLICATE_ENTRY = 1062;
@@ -418,7 +418,7 @@ class DibiMySqliDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -25,7 +25,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiOdbcDriver extends DibiObject implements IDibiDriver
class DibiOdbcDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
/** @var resource Connection resource */
private $connection;
@@ -368,7 +368,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -27,7 +27,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiOracleDriver extends DibiObject implements IDibiDriver
class DibiOracleDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
/** @var resource Connection resource */
private $connection;
@@ -356,7 +356,7 @@ class DibiOracleDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -423,55 +423,4 @@ class DibiPdoDriver extends DibiObject implements IDibiDriver
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;
}
}

View File

@@ -26,7 +26,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiPostgreDriver extends DibiObject implements IDibiDriver
class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
/** @var resource Connection resource */
private $connection;
@@ -388,7 +388,7 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -28,7 +28,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiSqliteDriver extends DibiObject implements IDibiDriver
class DibiSqliteDriver extends DibiObject implements IDibiDriver, IDibiReflector
{
/** @var resource Connection resource */
private $connection;
@@ -377,7 +377,7 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -26,7 +26,7 @@
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi\drivers
*/
class DibiSqlite3Driver extends DibiObject implements IDibiDriver
class DibiSqlite3Driver extends DibiObject implements IDibiDriver, IDibiReflector
{
/** @var SQLite3 Connection resource */
private $connection;
@@ -363,7 +363,7 @@ class DibiSqlite3Driver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/********************* IDibiReflector ****************d*g**/

View File

@@ -89,7 +89,7 @@ class DibiConnection extends DibiObject
$this->config = $config;
$this->driver = new $class;
// profiler
// profiler
$profilerCfg = & $config['profiler'];
if (is_numeric($profilerCfg) || is_bool($profilerCfg)) { // back compatibility
$profilerCfg = array('run' => (bool) $profilerCfg);
@@ -717,6 +717,9 @@ class DibiConnection extends DibiObject
*/
public function getDatabaseInfo()
{
if (!($this->driver instanceof IDibiReflector)) {
throw new NotSupportedException('Driver '. get_class($this->driver) . ' has not reflection capabilities.');
}
$this->connect();
return new DibiDatabaseInfo($this->driver, isset($this->config['database']) ? $this->config['database'] : NULL);
}

View File

@@ -24,7 +24,7 @@
*/
class DibiDatabaseInfo extends DibiObject
{
/** @var IDibiDriver */
/** @var IDibiReflector */
private $driver;
/** @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->name = $name;
@@ -145,7 +145,7 @@ class DibiDatabaseInfo extends DibiObject
*/
class DibiTableInfo extends DibiObject
{
/** @var IDibiDriver */
/** @var IDibiReflector */
private $driver;
/** @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->name = $info['name'];
@@ -349,7 +349,7 @@ class DibiTableInfo extends DibiObject
*/
class DibiResultInfo extends DibiObject
{
/** @var IDibiDriver */
/** @var IDibiReflector */
private $driver;
/** @var array */
@@ -360,7 +360,7 @@ class DibiResultInfo extends DibiObject
public function __construct(IDibiDriver $driver)
public function __construct(IDibiReflector $driver)
{
$this->driver = $driver;
}
@@ -466,7 +466,7 @@ class DibiColumnInfo extends DibiObject
/** @var array */
private static $types;
/** @var IDibiDriver */
/** @var IDibiReflector */
private $driver;
/** @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->info = $info;

View File

@@ -127,7 +127,7 @@ class DibiFluent extends DibiObject implements IDataSource
$this->command = $clause;
}
// auto-switch to a clause
// auto-switch to a clause
if (isset(self::$clauseSwitches[$clause])) {
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
}

View File

@@ -231,12 +231,20 @@ interface IDibiDriver
* @return mixed
*/
function getResultResource();
}
/********************* reflection ****************d*g**/
/**
* dibi driver reflection.
*
* @copyright Copyright (c) 2005, 2010 David Grudl
* @package dibi
*/
interface IDibiReflector
{
/**
* Returns list of tables.