Commit e0dcd111 authored by lsmith's avatar lsmith

- implemented listTriggers and listTableTriggers()

parent 73d63af1
...@@ -59,7 +59,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import ...@@ -59,7 +59,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
*/ */
public function listTriggers($database = null) public function listTriggers($database = null)
{ {
return $this->listTableTriggers(null);
} }
/** /**
...@@ -190,7 +190,24 @@ class Doctrine_Import_Sqlite extends Doctrine_Import ...@@ -190,7 +190,24 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
*/ */
public function listTableTriggers($table) public function listTableTriggers($table)
{ {
$query = "SELECT name FROM sqlite_master WHERE type='trigger' AND sql NOT NULL";
if (!is_null($table)) {
if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_FIX_CASE) {
if ($this->conn->getAttribute(Doctrine::ATTR_FIELD_CASE) == CASE_LOWER) {
$query.= ' AND LOWER(tbl_name)='.$db->quote(strtolower($table), 'text');
} else {
$query.= ' AND UPPER(tbl_name)='.$db->quote(strtoupper($table), 'text');
}
} else {
$query.= ' AND tbl_name='.$db->quote($table, 'text');
}
}
$result = $this->conn->fetchColumn($query);
if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_FIX_CASE) {
$result = array_map(($this->conn->getAttribute(Doctrine::ATTR_FIELD_CASE) == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
return $result;
} }
/** /**
...@@ -237,4 +254,4 @@ class Doctrine_Import_Sqlite extends Doctrine_Import ...@@ -237,4 +254,4 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
return $this->conn->fetchColumn($query); return $this->conn->fetchColumn($query);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment