Returns table primary key.
@return TablePrimaryKey
352779
protected function getTablePrimaryKey(): TablePrimaryKey
    {
        $data = [];

        /* @var $constraint Constraint */
        $constraint = $this->db->schema->getTablePrimaryKey($this->tableName, true);
        if ($constraint) {
            $data = [
                'columns' => $constraint->columnNames,
                'name' => $constraint->name,
            ];
        } elseif ($this->db->schema instanceof Schema) {
            // SQLite bug-case fixed in Yii 2.0.16 https://github.com/yiisoft/yii2/issues/16897

            if ($this->tableSchema !== null && $this->tableSchema->primaryKey) {
                $data = [
                    'columns' => $this->tableSchema->primaryKey,
                ];
            }
        }

        return new TablePrimaryKey($data);
    }
1167231
function GetPrimaryKeyName()
    {
        $fms = $this->_phreezer->GetFieldMaps(get_class($this));
        foreach ($fms as $fm)
        {
            if ($fm->IsPrimaryKey)
            {
				return $fm->PropertyName;
			}
        }

		/*
		print "<pre>";
		$this->Data = "";
		$this->_phreezer = null;
		$this->_cache = null;
		print_r($this);

		print_r($fms);
		die();
		*/

		throw new Exception("No Primary Key found for " . get_class($this));
    }
708780
public function getPrimaryKey($table)
    {
        if (! $table) {
            return '';
        }

        $sql = "SELECT cols.column_name
            FROM all_constraints cons, all_cons_columns cols
            WHERE upper(cols.table_name) = upper('{$table}')
                AND cons.constraint_type = 'P'
                AND cons.constraint_name = cols.constraint_name
                AND cons.owner = cols.owner
                AND cols.position = 1
                AND cons.owner = (select user from dual)
            ORDER BY cols.table_name, cols.position";
        $data = $this->connection->selectOne($sql);

        if ($data) {
            return $data->column_name;
        }

        return '';
    }
351152
public function getPrimaryKeyForForeignModel()
    {
        $model = $this->getForeignModelInstance();

        if ($this->isModel($model)) {
            return $model->getKeyName();
        }

        return $this->getKeyNameFromResource() ?: 'id';
    }
356804
public function getPrimarykey($table=null) 
    {
        if ($table) {
            return $this->getDb()->getPrimaryKey($table);
        } else {
            if (!isset($this->options['primary_key'])) {
                $pk = $this->getDb()->getPrimaryKey($this->getTableName());
                $this->options['primary_key'] = $pk;
            }
            
            return $this->options['primary_key'];
        }
    }
733364
public function getPrimaryKeyColumns()
    {
        $primaryKey = $this->getPrimaryKey();

        if ($primaryKey === null) {
            throw new DBALException('Table ' . $this->getName() . ' has no primary key.');
        }

        return $primaryKey->getColumns();
    }
490853
public static function getPrimaryKeyFromTable($tableName)
    {
        $schema = DB::getDoctrineSchemaManager();
        $indexes = collect($schema->listTableIndexes($tableName));

        $primaryKey = $indexes->first(function ($i, $index) {
            return $index->isPrimary() && 1 === count($index->getColumns());
        });

        return !empty($primaryKey) ? $primaryKey->getColumns()[0] : null;
    }
260913
protected function getPrimaryKeyColumn($entityMetadata)
    {
        $primaryKey = 'id';
        $incrementing = true;

        foreach ($entityMetadata['table']['columns'] as $column) {
            if ($column['primary']) {
                return $column;
            }
        }
    }
238704
public function getPrimaryKey($asColumn = false) {
		if ($asColumn)
			return $this->properties[$this->primaryKey]->getColumn();

		return $this->primaryKey;
	}
746075
public function getPrimaryKey()
    {
        $columns = $this->getColumns();

        if (!isset($columns)) {
            throw new DatabaseException('Column schema not found!');
        }

        if (count($columns) > 0) {
            $primaryKey = null;
            foreach ($columns as $key => $value) {
                if ($value['COLUMN_KEY'] == 'PRI' || $value['EXTRA'] == 'auto_increment') {
                    $primaryKey = $value['COLUMN_NAME'];
                    break;
                }
            }
        }

        return $primaryKey;
    }
1203565
public function getAutoIncrementPrimaryKey()
    {
        if (IdMethod::NO_ID_METHOD !== $this->getIdMethod()) {
            foreach ($this->getPrimaryKey() as $pk) {
                if ($pk->isAutoIncrement()) {
                    return $pk;
                }
            }
        }
    }
1086862
protected function findPrimaryKeys($table)
	{
		$pks=$this->getDbConnection()->getPdoInstance()->cubrid_schema(PDO::CUBRID_SCH_PRIMARY_KEY,$table->name);

		foreach($pks as $pk)
		{
			$c = $table->columns[$pk['ATTR_NAME']];
			$c->isPrimaryKey = true;

			if($table->primaryKey===null)
				$table->primaryKey=$c->name;
			elseif(is_string($table->primaryKey))
				$table->primaryKey=array($table->primaryKey,$c->name);
			else
				$table->primaryKey[]=$c->name;
			if($c->autoIncrement)
				$table->sequenceName='';
		}
	}
839377
public String getPrimaryKeysString() {

        String result = "";

        for (int i = 0; i < primaryKeys.length; i++) {
            if (result != "") {
                result += ", ";
            }

            result += primaryKeys[i];
        }    // end of for (int i=0; i<primaryKeys.length; i++)

        return result;
    }
379565
public function getPrimaryKey()
    {
        $keys = array();
        $columns = $this->getColumns(true);

        foreach ($columns as $name => $description)
        {
            if ($description->primary) {
                $keys[$name] = $description;
            }
        }

        return $keys;
    }
1020020
public function getPrimaryKey()
    {
        // 取表结构
        $meta = $this->meta();

        // 逐个寻找主键
        foreach ($meta as $field) {
            if ($field['primaryKey']) {
                return $field['name'];
            }
        }
        return false;
    }
42493
protected function getAlternatePrimaryKeys($table)
    {
        $alternatePrimaryKey = false;
        $primaryKeys = [];
        foreach ($table['columns'] as $column) {
            $columnName = $column['COLUMN_NAME'];
            $columnKey = $column['COLUMN_KEY'];
            if ($columnKey !== 'PRI') {
                continue;
            }
            if ($columnName !== 'id') {
                $alternatePrimaryKey = true;
            }
            $primaryKeys[] = '"' . $columnName . '"';
        }
        if ($alternatePrimaryKey) {
            return $primaryKeys;
        }

        return null;
    }
990659
public function getPrimaryKey()
    {
        if (null === $this->primary) {
            $metadata = $this->getMetadata();
            $constraints = $metadata->getConstraints($this->getTable());

            foreach ($constraints as $constraint) {
                if ($constraint->getType() == 'PRIMARY KEY') {
                    $this->primary = $constraint->getColumns();
                }
            }
        }

        return $this->primary;
    }