1
0
mirror of synced 2025-01-06 00:57:10 +03:00

refactored oracle import driver

This commit is contained in:
zYne 2007-01-15 22:21:27 +00:00
parent 6f7da981f9
commit 7e8310cebc

View File

@ -53,11 +53,6 @@ class Doctrine_Import_Oracle extends Doctrine_Import
$result2 = $this->conn->standaloneQuery($query, array('text'), false); $result2 = $this->conn->standaloneQuery($query, array('text'), false);
$result = $result2->fetchCol(); $result = $result2->fetchCol();
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE
&& $this->conn->options['field_case'] == CASE_LOWER
) {
$result = array_map(($this->conn->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
$result2->free(); $result2->free();
return $result; return $result;
} }
@ -69,14 +64,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public function listFunctions() public function listFunctions()
{ {
$query = "SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'"; $query = "SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'";
$result = $this->conn->fetchColumn($query); return $this->conn->fetchColumn($query);
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE
&& $this->conn->options['field_case'] == CASE_LOWER
) {
$result = array_map(($this->conn->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
return $result;
} }
/** /**
* lists all database triggers * lists all database triggers
@ -99,14 +87,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
$query = "SELECT sequence_name FROM sys.user_sequences"; $query = "SELECT sequence_name FROM sys.user_sequences";
$tableNames = $this->conn->fetchColumn($query); $tableNames = $this->conn->fetchColumn($query);
$result = array(); return array_map(array($this->conn, 'fixSequenceName'), $result);
foreach ($tableNames as $tableName) {
$result[] = $this->_fixSequenceName($tableName);
}
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE) {
$result = array_map(($this->conn->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
return $result;
} }
/** /**
* lists table constraints * lists table constraints
@ -122,20 +103,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
$query.= ' WHERE table_name='.$table.' OR table_name='.strtoupper($table); $query.= ' WHERE table_name='.$table.' OR table_name='.strtoupper($table);
$constraints = $this->conn->fetchColumn($query); $constraints = $this->conn->fetchColumn($query);
$result = array(); return array_map(array($this->conn, 'fixIndexName'), $constraints);
foreach ($constraints as $constraint) {
$constraint = $this->_fixIndexName($constraint);
if (!empty($constraint)) {
$result[$constraint] = true;
}
}
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE
&& $this->conn->options['field_case'] == CASE_LOWER
) {
$result = array_change_key_case($result, $this->conn->options['field_case']);
}
return array_keys($result);
} }
/** /**
* lists table constraints * lists table constraints
@ -174,20 +142,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
$query.= ' AND generated=' .$this->conn->quote('N', 'text'); $query.= ' AND generated=' .$this->conn->quote('N', 'text');
$indexes = $this->conn->fetchColumn($query); $indexes = $this->conn->fetchColumn($query);
$result = array(); return array_map(array($this->conn, 'fixIndexName'), $indexes);
foreach ($indexes as $index) {
$index = $this->_fixIndexName($index);
if (!empty($index)) {
$result[$index] = true;
}
}
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE
&& $this->conn->options['field_case'] == CASE_LOWER
) {
$result = array_change_key_case($result, $this->conn->options['field_case']);
}
return array_keys($result);
} }
/** /**
* lists tables * lists tables
@ -198,14 +153,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public function listTables($database = null) public function listTables($database = null)
{ {
$query = 'SELECT table_name FROM sys.user_tables'; $query = 'SELECT table_name FROM sys.user_tables';
$result = $this->conn->fetchColumn($query); return $this->conn->fetchColumn($query);
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE
&& $this->conn->options['field_case'] == CASE_LOWER
) {
$result = array_map(($this->conn->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
return $result;
} }
/** /**
* lists table triggers * lists table triggers
@ -253,13 +201,6 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public function listViews($database = null) public function listViews($database = null)
{ {
$query = 'SELECT view_name FROM sys.user_views'; $query = 'SELECT view_name FROM sys.user_views';
$result = $this->conn->fetchColumn($query); return $this->conn->fetchColumn($query);
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE
&& $this->conn->options['field_case'] == CASE_LOWER
) {
$result = array_map(($this->conn->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result);
}
return $result;
} }
} }