Beispiel #1
0
 /**
  *(non-PHPdoc)
  * @see jemdev\dbrm\init\getSchemaInfos::_getReferencesFK()
  */
 public function getReferencesFK($table)
 {
     $sql = "SELECT " . "    COLUMN_NAME, " . "    REFERENCED_TABLE_NAME, " . "    REFERENCED_COLUMN_NAME " . "FROM " . $this->_metaschema . ".KEY_COLUMN_USAGE " . "WHERE CONSTRAINT_SCHEMA = :P_CONSTRAINT_SCHEMA " . "  AND TABLE_NAME = :P_TABLE_NAME " . "  AND REFERENCED_TABLE_NAME IS NOT NULL";
     $params = array(':P_CONSTRAINT_SCHEMA' => $this->_schemacible, ':P_TABLE_NAME' => $table);
     $this->_oVue->setRequete($sql, $params);
     $aRef = $this->_oVue->fetchAssoc();
     return $aRef;
 }
Beispiel #2
0
 /**
  *(non-PHPdoc)
  * @see jemdev\dbrm\init\getSchemaInfos::_getReferencesFK()
  */
 public function getReferencesFK($table)
 {
     $sql = "SELECT" . PHP_EOL . "  kc.column_name        AS COLUMN_NAME," . PHP_EOL . "  cc.table_name         AS REFERENCED_TABLE_NAME," . PHP_EOL . "  cc.column_name        AS REFERENCED_COLUMN_NAME" . PHP_EOL . "FROM " . $this->_metaschema . ".table_constraints               tc" . PHP_EOL . "  LEFT JOIN " . $this->_metaschema . ".key_column_usage         kc ON tc.constraint_catalog = kc.constraint_catalog" . PHP_EOL . "                                                          AND tc.constraint_schema = kc.constraint_schema" . PHP_EOL . "                                                          AND tc.constraint_name = kc.constraint_name" . PHP_EOL . "  LEFT JOIN " . $this->_metaschema . ".referential_constraints  rc ON tc.constraint_catalog = rc.constraint_catalog" . PHP_EOL . "                                                          AND tc.constraint_schema = rc.constraint_schema" . PHP_EOL . "                                                          AND tc.constraint_name = rc.constraint_name" . PHP_EOL . "  LEFT JOIN " . $this->_metaschema . ".constraint_column_usage  cc ON rc.unique_constraint_catalog = cc.constraint_catalog" . PHP_EOL . "                                                          AND rc.unique_constraint_schema = cc.constraint_schema" . PHP_EOL . "                                                          AND rc.unique_constraint_name = cc.constraint_name" . PHP_EOL . "WHERE tc.table_name       = :P_TABLE_NAME" . PHP_EOL . "  AND tc.table_catalog    = :P_CONSTRAINT_SCHEMA" . PHP_EOL . "  AND tc.constraint_type  = :P_TYPE_FK";
     $params = array(':P_CONSTRAINT_SCHEMA' => $this->_schemacible, ':P_TABLE_NAME' => $table, ':P_TYPE_FK' => $this->_type_fk);
     $this->_oVue->setRequete($sql, $params);
     $aRef = $this->_oVue->fetchAssoc();
     return $aRef;
 }