diff --git a/dibi/drivers/firebird.php b/dibi/drivers/firebird.php index 6344f2ba..50935c19 100644 --- a/dibi/drivers/firebird.php +++ b/dibi/drivers/firebird.php @@ -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 ********************/ diff --git a/dibi/drivers/mssql.php b/dibi/drivers/mssql.php index 0c14ffed..f3a2d0ed 100644 --- a/dibi/drivers/mssql.php +++ b/dibi/drivers/mssql.php @@ -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; - } - } diff --git a/dibi/drivers/mssql2005.php b/dibi/drivers/mssql2005.php index 1ae5cd1d..03bb059e 100644 --- a/dibi/drivers/mssql2005.php +++ b/dibi/drivers/mssql2005.php @@ -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; - } - } diff --git a/dibi/drivers/mysql.php b/dibi/drivers/mysql.php index 6617204a..aabfa4fe 100644 --- a/dibi/drivers/mysql.php +++ b/dibi/drivers/mysql.php @@ -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**/ diff --git a/dibi/drivers/mysqli.php b/dibi/drivers/mysqli.php index 4198b6ad..67e215da 100644 --- a/dibi/drivers/mysqli.php +++ b/dibi/drivers/mysqli.php @@ -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**/ diff --git a/dibi/drivers/odbc.php b/dibi/drivers/odbc.php index 8e49985a..00d25a71 100644 --- a/dibi/drivers/odbc.php +++ b/dibi/drivers/odbc.php @@ -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**/ diff --git a/dibi/drivers/oracle.php b/dibi/drivers/oracle.php index ff839007..4a949698 100644 --- a/dibi/drivers/oracle.php +++ b/dibi/drivers/oracle.php @@ -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**/ diff --git a/dibi/drivers/pdo.php b/dibi/drivers/pdo.php index 5e8d91d5..842cfbd0 100644 --- a/dibi/drivers/pdo.php +++ b/dibi/drivers/pdo.php @@ -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; - } - } diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index f94d3d78..6e2a2bfd 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -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**/ diff --git a/dibi/drivers/sqlite.php b/dibi/drivers/sqlite.php index 75524846..85ff03d9 100644 --- a/dibi/drivers/sqlite.php +++ b/dibi/drivers/sqlite.php @@ -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**/ diff --git a/dibi/drivers/sqlite3.php b/dibi/drivers/sqlite3.php index 6f309dbb..7136760a 100644 --- a/dibi/drivers/sqlite3.php +++ b/dibi/drivers/sqlite3.php @@ -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**/ diff --git a/dibi/libs/DibiConnection.php b/dibi/libs/DibiConnection.php index 85e64be4..7fb82517 100644 --- a/dibi/libs/DibiConnection.php +++ b/dibi/libs/DibiConnection.php @@ -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); } diff --git a/dibi/libs/DibiDatabaseInfo.php b/dibi/libs/DibiDatabaseInfo.php index 0c0e5593..84426228 100644 --- a/dibi/libs/DibiDatabaseInfo.php +++ b/dibi/libs/DibiDatabaseInfo.php @@ -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; diff --git a/dibi/libs/DibiFluent.php b/dibi/libs/DibiFluent.php index 2f35d2ae..a5562f40 100644 --- a/dibi/libs/DibiFluent.php +++ b/dibi/libs/DibiFluent.php @@ -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]]; } diff --git a/dibi/libs/interfaces.php b/dibi/libs/interfaces.php index 734cb7c5..230a4557 100644 --- a/dibi/libs/interfaces.php +++ b/dibi/libs/interfaces.php @@ -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.