private function GetForeignKey($table, $field, &$constraintName, &$refTable, &$refField)
    {
        $sql = new Sql\Builder($this);

        $tbl = $sql->Table('information_schema.key_column_usage', array('TABLE_SCHEMA', 'TABLE_NAME', 'COLUMN_NAME',
            'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'));

        $cond = $sql->Equals($tbl->Field('TABLE_SCHEMA'), $sql->Value($this->dbName))
                ->And_($sql->Equals($tbl->Field('TABLE_NAME'), $sql->Value($table)))
                ->And_($sql->Equals($tbl->Field('COLUMN_NAME'), $sql->Value($field)))
                ->And_($sql->IsNotNull($tbl->Field('REFERENCED_TABLE_NAME')));

        $what = $sql->SelectList($tbl->Field('REFERENCED_TABLE_NAME'));
        $what->Add($tbl->Field('REFERENCED_COLUMN_NAME'));
        $what->Add($tbl->Field('CONSTRAINT_NAME'));
        $select = $sql->Select(true, $what, $tbl, $cond);
        $reader = $this->ExecuteQuery((string) $select);
        if ($reader->Read())
        {
            $constraintName = (string) $reader->ByName('CONSTRAINT_NAME');
            $refTable = (string) $reader->ByName('REFERENCED_TABLE_NAME');
            $refField = (string) $reader->ByName('REFERENCED_COLUMN_NAME');
            return true;
        }
        return false;
    }
private function GetForeignKey($table, $field, &$constraintName, &$refTable, &$refField)
    {
        $sql = new Sql\Builder($this);

        $tbl = $sql->Table('information_schema.key_column_usage', array('TABLE_SCHEMA', 'TABLE_NAME', 'COLUMN_NAME',
            'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'));

        $cond = $sql->Equals($tbl->Field('TABLE_SCHEMA'), $sql->Value($this->dbName))
                ->And_($sql->Equals($tbl->Field('TABLE_NAME'), $sql->Value($table)))
                ->And_($sql->Equals($tbl->Field('COLUMN_NAME'), $sql->Value($field)))
                ->And_($sql->IsNotNull($tbl->Field('REFERENCED_TABLE_NAME')));

        $what = $sql->SelectList($tbl->Field('REFERENCED_TABLE_NAME'));
        $what->Add($tbl->Field('REFERENCED_COLUMN_NAME'));
        $what->Add($tbl->Field('CONSTRAINT_NAME'));
        $select = $sql->Select(true, $what, $tbl, $cond);
        $reader = $this->ExecuteQuery((string) $select);
        if ($reader->Read())
        {
            $constraintName = (string) $reader->ByName('CONSTRAINT_NAME');
            $refTable = (string) $reader->ByName('REFERENCED_TABLE_NAME');
            $refField = (string) $reader->ByName('REFERENCED_COLUMN_NAME');
            return true;
        }
        return false;
    }
private function GetForeignKey ( $ table , $ field , & $ constraintName , & $ refTable , & $ refField ) { $ sql = new Sql \ Builder ( $ this ) ; $ tbl = $ sql -> Table ( 'information_schema.key_column_usage' , array ( 'TABLE_SCHEMA' , 'TABLE_NAME' , 'COLUMN_NAME' , 'CONSTRAINT_NAME' , 'REFERENCED_TABLE_NAME' , 'REFERENCED_COLUMN_NAME' ) ) ; $ cond = $ sql -> Equals ( $ tbl -> Field ( 'TABLE_SCHEMA' ) , $ sql -> Value ( $ this -> dbName ) ) -> And_ ( $ sql -> Equals ( $ tbl -> Field ( 'TABLE_NAME' ) , $ sql -> Value ( $ table ) ) ) -> And_ ( $ sql -> Equals ( $ tbl -> Field ( 'COLUMN_NAME' ) , $ sql -> Value ( $ field ) ) ) -> And_ ( $ sql -> IsNotNull ( $ tbl -> Field ( 'REFERENCED_TABLE_NAME' ) ) ) ; $ what = $ sql -> SelectList ( $ tbl -> Field ( 'REFERENCED_TABLE_NAME' ) ) ; $ what -> Add ( $ tbl -> Field ( 'REFERENCED_COLUMN_NAME' ) ) ; $ what -> Add ( $ tbl -> Field ( 'CONSTRAINT_NAME' ) ) ; $ select = $ sql -> Select ( true , $ what , $ tbl , $ cond ) ; $ reader = $ this -> ExecuteQuery ( ( string ) $ select ) ; if ( $ reader -> Read ( ) ) { $ constraintName = ( string ) $ reader -> ByName ( 'CONSTRAINT_NAME' ) ; $ refTable = ( string ) $ reader -> ByName ( 'REFERENCED_TABLE_NAME' ) ; $ refField = ( string ) $ reader -> ByName ( 'REFERENCED_COLUMN_NAME' ) ; return true ; } return false ; }
Gets foreign key parameters
@param string $table The table name as input parameter
@param type $field The field name as input parameter
@param type $constraintName The constraint name as output parameter
@param type $refTable The reference table name as output parameter
@param string $refField The reference table field name as output parameter
@return boolean Returns true if foreign key infos where found
Gets foreign key parameters