1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-13 09:34:30 +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

@@ -199,6 +199,22 @@ class DibiOdbcDriver 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.
*
@@ -269,6 +285,10 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
/********************* result set ****************d*g**/
/**
* Returns the number of rows in a result set.
*
@@ -347,7 +367,7 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
$meta[] = array(
'name' => odbc_field_name($this->resultSet, $i),
'table' => NULL,
'type' => odbc_field_type($this->resultSet, $i),
'nativetype'=> odbc_field_type($this->resultSet, $i),
'length' => odbc_field_len($this->resultSet, $i),
'scale' => odbc_field_scale($this->resultSet, $i),
'precision' => odbc_field_precision($this->resultSet, $i),
@@ -358,18 +378,6 @@ class DibiOdbcDriver extends DibiObject implements IDibiDriver
/**
* Returns the connection resource.
*
* @return mixed
*/
public function getResource()
{
return $this->connection;
}
/**
* Returns the result set resource.
*
@@ -382,12 +390,58 @@ class DibiOdbcDriver 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()
{
$result = odbc_tables($this->connection);
$res = array();
while (odbc_fetch_row($result)) {
$res[] = array('name' => odbc_result($result, 'TABLE_NAME'));
}
return $res;
}
/**
* 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;
}
}