1
0
mirror of synced 2024-12-14 07:06:04 +03:00

ported listTableViews and listViews from MDB2 cvs

This commit is contained in:
zYne 2007-03-07 09:59:44 +00:00
parent 164138af6c
commit e68b193c0a

View File

@ -188,7 +188,18 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
*/ */
public function listTableViews($table) public function listTableViews($table)
{ {
$query = "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL";
$views = $db->fetchAll($query);
$result = array();
foreach ($views as $row) {
if (preg_match("/^create view .* \bfrom\b\s+\b{$table}\b /i", $row['sql'])) {
if ( ! empty($row['name'])) {
$result[$row['name']] = true;
}
}
}
return $result;
} }
/** /**
* lists database users * lists database users
@ -207,7 +218,9 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
*/ */
public function listViews($database = null) public function listViews($database = null)
{ {
$query = "SELECT name FROM sqlite_master WHERE type='view' AND sql NOT NULL";
return $this->conn->fetchColumn($query);
} }
} }