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

@@ -560,18 +560,35 @@ class DibiResult extends DibiObject implements IDataSource
/**
* Gets an array of meta informations about column.
*
* @return array
* @return array of DibiColumnInfo
*/
final public function getColumnsMeta()
final public function getColumns()
{
if ($this->metaCache === NULL) {
$this->metaCache = $this->getDriver()->getColumnsMeta();
}
$cols = array();
foreach ($this->metaCache as $col) {
$name = (!$this->withTables || $col['table'] === NULL) ? $col['name'] : ($col['table'] . '.' . $col['name']);
$cols[$name] = $col;
foreach ($this->metaCache as $info) {
$cols[] = new DibiColumnInfo($this->driver, $info);
}
return $cols;
}
/**
* @param bool
* @return array of string
*/
public function getColumnNames($withTables = FALSE)
{
if ($this->metaCache === NULL) {
$this->metaCache = $this->getDriver()->getColumnsMeta();
}
$cols = array();
foreach ($this->metaCache as $info) {
$cols[] = (!$withTables || $info['table'] === NULL) ? $info['name'] : ($info['table'] . '.' . $info['name']);
}
return $cols;
}