Gets the generic table primary key.

The $primaryKey parameter must contain:
- name
- column_name

@param array $primaryKey The primary key.

@return \Fridge\DBAL\Schema\PrimaryKey|null The generic primary key.
6871
protected function getGenericPrimaryKey(array $primaryKey)
    {
        $genericPrimaryKey = new PrimaryKey($primaryKey[0]['name']);

        foreach ($primaryKey as $primaryKeyColumn) {
            $genericPrimaryKey->addColumnName($primaryKeyColumn['column_name']);
        }

        return $genericPrimaryKey;
    }
807990
public function primaryKey ($tableName)
		{
			if (! isset($this->primaryKeys[$tableName])) {
				$sql = "SELECT *
					    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
					        JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name
					    WHERE tc.CONSTRAINT_TYPE = 'Primary Key'
					        AND tc.TABLE_NAME = " . $this->quote($tableName);

				$keyResult                      = $this->query($sql);
				$key                            = $keyResult->fetchRow();
				$this->primaryKeys[$tableName]  = $key['COLUMN_NAME'];
			}

			return $this->primaryKeys[$tableName];
		}
995240
public function find( $primaryKeys )
    {
        if ( is_array( $primaryKeys ) )
        {
            $primaryKeys = reset( $primaryKeys );
        }

        $rootId = ( (int) $primaryKeys ) ?: null;

        return $this->createStructure( array(
            'rootId'    => $rootId,
            'extra'     => $this->getExtraMapper()
                                ->findByRoot( $rootId ),
            'rules'     => $this->getRuleMapper()
                                ->findAllByRoot(
                                    $rootId,
                                    $this->getRuleOrder()
                                ),
        ) );
    }
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;
    }
1317003
public function primary()
    {
        $key = $this->tableHasPrimary()->getPrimaryKey();
        $message = "The column {$this->name} is not a primary key.";

        return $this->assertTrue(in_array($this->name, $key->getColumns()), $message)
                    ->assertTrue($key->isPrimary())
                    ->assertTrue($key->isUnique());
    }
628112
protected function getPrimaryKey(): array
    {
        $primary = array_flip($this->getTable()->getPrimaryKey());

        return array_intersect_key($this->toArray(), $primary);
    }
1177156
public function lastInsertId($tableName = null, $primaryKey = null)
    {
        return $this->db->lastInsertId($tableName, $primaryKey);
    }
899426
public function setPrimaryKey($column) : Table
    {
        if (!is_array($column)) {
            $column = [ $column ];
        }
        $this->data['primary'] = $column;
        return $this;
    }
780489
public function primaryKey()
    {
        if (empty($this->_context['schema']['_constraints']) ||
            !is_array($this->_context['schema']['_constraints'])
        ) {
            return [];
        }
        foreach ($this->_context['schema']['_constraints'] as $data) {
            if (isset($data['type']) && $data['type'] === 'primary') {
                return isset($data['columns']) ? (array)$data['columns'] : [];
            }
        }

        return [];
    }
466029
public function delete($primaryKey)
    {
        return $this->app['db']->delete($this->getTable(), [ $this->getPrimaryKey() => $primaryKey]);
    }
773820
public function primary(Table $table, Fluent $command)
		{
			return $this->key($table, $command->name(null), 'PRIMARY KEY');
		}
817636
public function getPrimaryKeyName()
    {
        if (!isset($this->primaryKeyName)) {
            // lazy load
            $memory = $this->getDI()->get('memory');
            $attributes = $memory->getPrimaryKeyAttributes($this);
            $attributeKey = $attributes[0];

            // adjust for colMaps if any are provided
            $colMap = $memory->getColumnMap($this);
            if (is_null($colMap)) {
                $this->primaryKeyName = $attributeKey;
            } else {
                $this->primaryKeyName = $colMap[$attributeKey];
            }
        }
        return $this->primaryKeyName;
    }
959101
public function find( $primaryKeys )
    {
        $id = is_array( $primaryKeys ) ? reset( $primaryKeys ) : $primaryKeys;

        if ( empty( $id ) )
        {
            return null;
        }

        $paragraph = $this->getParagraphMapper()
                          ->find( $id );

        if ( empty( $paragraph ) )
        {
            return null;
        }

        $rules      = array();
        $selectors  = $this->getCustomization()
                           ->getSelectorsByParagraph( $paragraph );

        foreach ( $selectors as $key => $selector )
        {
            $rootId = $paragraph->rootId;
            $rule   = $this->getCustomizeRuleMapper()
                           ->findBySelector( $selector, '', $rootId );

            if ( empty( $rule ) )
            {
                $rule = $this->getCustomizeRuleMapper()
                             ->create( array(
                                 'media'            => '',
                                 'selector'         => $selector,
                                 'rootParagraphId'  => $rootId,
                             ) );
            }

            $rules[$key] = $rule;
        }

        return $this->createStructure( array(
            'paragraph' => $paragraph,
            'rules'     => $rules,
        ) );
    }
1003700
protected function retrieveByPrimaryKey(array $primary_key_values) {
		/** @var DynamicEntity $entity */
		$entity = parent::retrieveByPrimaryKey($primary_key_values);
		if ($entity) {
			$entity->definition = $this->definition;
		}
		return $entity;
	}
1350843
private static function generatePrimaryKey(array $pk, array $columns)
    {
        if (empty($pk)) {
            return '';
        }
        // Composite primary keys
        if (2 <= count($pk)) {
            $compositePk = implode(', ', $pk);
            return "    'PRIMARY KEY ($compositePk)',\n";
        }
        // Primary key not an auto-increment
        $flag = false;
        foreach ($columns as $column) {
            if ($column->autoIncrement) {
                $flag = true;
            }
        }
        if (false === $flag) {
            return sprintf("    'PRIMARY KEY (%s)',\n", $pk[0]);
        }
        return '';
    }
1354234
private function preparePrimaryKey(array $primaryKey)
	{
		$result = array();
		foreach ($primaryKey as $key => $value) {
			$result[$key] = array(
				$this->getValueType($value) => $value
			);
		}
Debugger::barDump($result);
		return $result;
	}
1371775
public function getPrimaryKey()
    {
        if (null == $this->primaryKey) {
            foreach ($this->getFields() as $field) {
                if ($field->isPrimaryKey()) {
                    $this->primaryKey = $field;
                    break;
                }
            }
        }
        return $this->primaryKey;
    }