protected function getConstraintKeys($schemaName, $tableName)
{
$this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
// select decode( a.CONSTRAINT_TYPE, 'P', 'PRIMARY KEY (', 'FOREIGN KEY (' )||b.COLUMN_NAME||')' as consrc,
$sql = <<<EOD
\t\tselect b.COLUMN_NAME as consrc,
\t\t\t a.CONSTRAINT_TYPE as contype
\t\tfrom ALL_CONSTRAINTS a, ALL_CONS_COLUMNS b
\t\twhere (a.constraint_name = b.constraint_name AND a.table_name = b.table_name AND a.owner = b.owner)
\t\tand\t a.TABLE_NAME = '{$tableName}'
\t\tand a.OWNER = '{$schemaName}'
\t\tand a.CONSTRAINT_TYPE in ('P','R')
EOD;
$this->getDbConnection()->setActive(true);
$command = $this->getDbConnection()->createCommand($sql);
//$command->bindValue(':table', $tableName);
//$command->bindValue(':schema', $schemaName);
$primary = array();
$foreign = array();
foreach ($command->query() as $row) {
switch (strtolower($row['contype'])) {
case 'p':
$primary = array_merge($primary, array(strtolower($row['consrc'])));
/*
$arr = $this->getPrimaryKeys($row['consrc']);
$primary = array_merge( $primary, array(strtolower( $arr[0] )) );
*/
break;
case 'r':
$foreign = array_merge($foreign, array(strtolower($row['consrc'])));
/*
// if(($fkey = $this->getForeignKeys($row['consrc']))!==null)
$fkey = $this->getForeignKeys( $row['consrc'] );
$foreign = array_merge( $foreign, array(strtolower( $fkey )) );
*/
break;
}
}
return array($primary, $foreign);
}