1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-06 06:07:39 +02:00

- implemented basic meta/reflection support

This commit is contained in:
David Grudl
2008-10-02 17:13:43 +00:00
parent fc69f8f47b
commit b0f155f767
14 changed files with 1223 additions and 170 deletions

View File

@@ -202,6 +202,22 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/**
* Returns the connection resource.
*
* @return mixed
*/
public function getResource()
{
return $this->connection;
}
/********************* SQL ****************d*g**/
/**
* Encodes data for use in an SQL statement.
*
@@ -267,6 +283,10 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/********************* result set ****************d*g**/
/**
* Returns the number of rows in a result set.
*
@@ -335,10 +355,13 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
$count = sqlite_num_fields($this->resultSet);
$meta = array();
for ($i = 0; $i < $count; $i++) {
// items 'name' and 'table' are required
$pair = explode('.', sqlite_field_name($this->resultSet, $i));
if (!isset($pair[1])) {
array_unshift($pair, NULL);
}
$meta[] = array(
'name' => sqlite_field_name($this->resultSet, $i),
'table' => NULL,
'name' => $pair[1],
'table' => $pair[0],
);
}
return $meta;
@@ -346,18 +369,6 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/**
* Returns the connection resource.
*
* @return mixed
*/
public function getResource()
{
return $this->connection;
}
/**
* Returns the result set resource.
*
@@ -370,12 +381,57 @@ class DibiSqliteDriver extends DibiObject implements IDibiDriver
/********************* reflection ****************d*g**/
/**
* Gets a information of the current database.
*
* @return DibiReflection
* Returns list of tables.
* @return array
*/
function getDibiReflection()
{}
public function getTables()
{
$this->query("
SELECT name FROM sqlite_master WHERE type='table'
UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name
");
return sqlite_fetch_all($this->resultSet, SQLITE_ASSOC);
}
/**
* 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;
}
}