Prado\Data\Common\Mysql\TMysqlMetaData::getConstraintKeys PHP 메소드

getConstraintKeys() 보호된 메소드

Gets the primary and foreign key column details for the given table.
protected getConstraintKeys ( $schemaName, $tableName ) : array
리턴 array tuple ($primary, $foreign)
    protected function getConstraintKeys($schemaName, $tableName)
    {
        $table = $schemaName === null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`";
        $sql = "SHOW INDEX FROM {$table}";
        $command = $this->getDbConnection()->createCommand($sql);
        $primary = array();
        foreach ($command->query() as $row) {
            if ($row['Key_name'] === 'PRIMARY') {
                $primary[] = $row['Column_name'];
            }
        }
        // MySQL version was increased to >=5.1.21 instead of 5.x
        // due to a MySQL bug (http://bugs.mysql.com/bug.php?id=19588)
        if ($this->getServerVersion() >= 5.121) {
            $foreign = $this->getForeignConstraints($schemaName, $tableName);
        } else {
            $foreign = $this->findForeignConstraints($schemaName, $tableName);
        }
        return array($primary, $foreign);
    }