예제 #1
0
파일: Table.php 프로젝트: juyagu/Analia
 /**
  * Obtiene el detalle de las foreign keys del esquema
  * @return Array
  */
 public function checkTableForeignKeys()
 {
     $sql = "select uc.constraint_name, uc.table_name, ucc.column_name, uc.r_constraint_name, destino.table_name as r_table_name, " . "destino.column_name as r_column_name, uc.status " . "from user_constraints uc " . "inner join user_cons_columns destino on uc.r_constraint_name = destino.constraint_name " . "inner join user_cons_columns ucc on uc.constraint_name = ucc.constraint_name " . "where uc.constraint_type = 'R' " . "and uc.owner = upper(:v_owner) " . "and uc.table_name = upper(:v_table) " . "order by uc.table_name, uc.r_constraint_name, destino.table_name, destino.column_name";
     $stmt = oci_parse($this->getConnection(), $sql);
     oci_bind_by_name($stmt, ":v_table", $this->objectName);
     oci_bind_by_name($stmt, ":v_owner", $this->owner);
     if (!@oci_execute($stmt)) {
         $e = oci_error();
         $this->setMensaje("Error al obtener el detalle de las claves foráneas de la tabla o vista '{$this->objectName}' - {$e['message']}");
         $this->setEstado(false);
     }
     while ($row = oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS)) {
         $foreignKey = new ForeignKey();
         $foreignKey->setConstraintName($row['CONSTRAINT_NAME']);
         $foreignKey->setTableName($row['TABLE_NAME']);
         $foreignKey->setColumnName($row['COLUMN_NAME']);
         $foreignKey->setReferenceConstraintName($row['R_CONSTRAINT_NAME']);
         $foreignKey->setReferenceTableName($row['R_TABLE_NAME']);
         $foreignKey->setReferenceColumnName($row['R_COLUMN_NAME']);
         $foreignKey->setStatus($row['STATUS']);
         $this->aForeignKeys[] = $foreignKey;
     }
     return $this->aForeignKeys;
 }