Compares two primary keys.

@param \Fridge\DBAL\Schema\PrimaryKey $oldPrimaryKey The old primary key.
@param \Fridge\DBAL\Schema\PrimaryKey $newPrimaryKey The new primary key.

@return boolean TRUE if the primary keys are different else FALSE.
424214
public function comparePrimaryKeys(PrimaryKey $oldPrimaryKey, PrimaryKey $newPrimaryKey)
    {
        return ($oldPrimaryKey->getName() !== $newPrimaryKey->getName())
            || ($oldPrimaryKey->getColumnNames() !== $newPrimaryKey->getColumnNames());
    }
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;
    }
466129
public function hasPrimaryKey() {

        $pks = (array) $this->pk;
        $ret = true;

        foreach($pks as $pk) {

            $value = $this->getProperty($pk);
            if (empty($value)) {
                return false;
            }

        }

        return $ret;

    }
611638
protected function isPrimaryKey(Table $table, Column $column)
	{
		if ($table->hasPrimaryKey()) {
			$primaryKeys = $table->getPrimaryKey()->getColumns();

			return in_array($column->getName(), $primaryKeys);
		}

		return false;
	}
1099039
boolean isPrimaryKey(int col) {
    if (primaryKeys[col] != null) {
      return primaryKeys[col];
    }

    try {
      // Convert column index into JDBC column number.
      int colNum = col + 1;

      // If the table name can't be determined exit quickly.
      // this doesn't always work, since some JDBC drivers (e.g.,
      // Oracle's) return a blank string from getTableName.
      String table = rsMeta.getTableName(colNum);
      if (table == null || table.length() == 0) {
        return primaryKeys[col] = false;
      }

      // If the column name can't be determined exit quickly.
      String column = rsMeta.getColumnName(colNum);
      if (column == null || column.length() == 0) {
        return primaryKeys[col] = false;
      }

      // Retrieve the catalog and schema name for this connection.
      // Either or both may be null.
      final DatabaseMetaData dbMeta =
          sqlLine.getDatabaseConnection().meta;
      String catalog = dbMeta.getConnection().getCatalog();
      String schema = rsMeta.getSchemaName(colNum);

      // Get the (possibly cached) set of primary key columns
      // for the table containing this column.
      Set<String> tablePrimaryKeys =
          getTablePrimaryKeys(catalog, schema, table);

      // Determine if this column is a primary key and cache the result.
      return primaryKeys[col] = tablePrimaryKeys != null
          && tablePrimaryKeys.contains(column);

    } catch (SQLException e) {
      // Ignore the exception and assume that this column
      // isn't a primary key for display purposes.
      return primaryKeys[col] = false;
    }
  }
1129393
public function rekey( Base $entity )
    {

        if( false !== $key = array_search( $entity, $this->instancesPersisted, true ) ) {

            $newKey = $entity->keyGet( $entity );

            if( isset( $this->instancesPersisted[$newKey] ) and $entity !== $this->instancesPersisted[$newKey] ) {
                throw new \RuntimeException( "Different object already exists with this same `key`. Clear collision." );
            }

            unset( $this->instancesPersisted[$key] );
            $this->instancesPersisted[$newKey] = $entity;
            return true;

        }

        return false;

    }
689552
public function getPrimaryKey()
    {
        if ($this->_primaryKey === null) {
            $key = (array)$this->getSchema()->primaryKey();
            if (count($key) === 1) {
                $key = $key[0];
            }
            $this->_primaryKey = $key;
        }

        return $this->_primaryKey;
    }
442782
protected function getPrimaryKey()
    {
        if (!isset($this->values[static::$primary_key])) {
            throw new \LogicException('Primary key not set');
        }

        return $this->current_index ?: $this->values[static::$primary_key];
    }
1099831
public function hasAutoIncrementPrimaryKey()
    {
        if ($this->getIdMethod() != IDMethod::NO_ID_METHOD) {
            $pks = $this->getPrimaryKey();
            foreach ($pks as $pk) {
                if ($pk->isAutoIncrement()) {
                    return true;
                }
            }
        }

        return false;
    }
156478
public function isAtLeastOneLocalPrimaryKey()
    {
        $localCols = $this->getLocalColumnObjects();

        foreach ($localCols as $localCol) {
            if ($this->getTable()->getColumn($localCol->getName())->isPrimaryKey()) {
                return true;
            }
        }

        return false;
    }
1371775
public function getPrimaryKey()
    {
        if (null == $this->primaryKey) {
            foreach ($this->getFields() as $field) {
                if ($field->isPrimaryKey()) {
                    $this->primaryKey = $field;
                    break;
                }
            }
        }
        return $this->primaryKey;
    }
1332296
public function primaryKey($key = null)
    {
        deprecationWarning(
            get_called_class() . '::primaryKey() is deprecated. ' .
            'Use setPrimaryKey()/getPrimaryKey() instead.'
        );
        if ($key !== null) {
            $this->setPrimaryKey($key);
        }

        return $this->getPrimaryKey();
    }
156284
public function primary($pkeys) {
        if (empty($pkeys))
            return false;
        if (!is_array($pkeys))
            $pkeys = array($pkeys);
        // single pkey
        $this->increments = $pkeys[0];
        $this->pkeys = $pkeys;
        // drop duplicate pkey definition
        if (array_key_exists($this->increments,$this->columns))
            unset($this->columns[$this->increments]);
        // set flag on new fields
        foreach ($pkeys as $name)
            if(array_key_exists($name,$this->columns))
                $this->columns[$name]->pkey = true;
        // composite key
        if (count($pkeys) > 1) {
            $pkeys_quoted = array_map(array($this->db,'quotekey'), $pkeys);
            $pk_string = implode(', ', $pkeys_quoted);
            if (preg_match('/sqlite2?/', $this->db->driver())) {
                // rebuild table with new primary keys
                $this->rebuild_cmd['pkeys'] = $pkeys;
                return;
            } else {
                $table = $this->db->quotekey($this->name);
                $table_key = $this->db->quotekey($this->name.'_pkey');
                $cmd = array(
                    'odbc' =>
                        "CREATE INDEX $table_key ON $table ( $pk_string );",
                    'mysql' =>
                        "ALTER TABLE $table DROP PRIMARY KEY, ADD PRIMARY KEY ( $pk_string );",
                    'mssql|sybase|dblib|sqlsrv' => array(
                        "ALTER TABLE $table DROP CONSTRAINT PK_".$this->name."_ID;",
                        "ALTER TABLE $table ADD CONSTRAINT $table_key PRIMARY KEY ( $pk_string );",
                    ),
                    'pgsql' => array(
                        "ALTER TABLE $table DROP CONSTRAINT $table_key;",
                        "ALTER TABLE $table ADD CONSTRAINT $table_key PRIMARY KEY ( $pk_string );",
                    ),
                );
                $query = $this->findQuery($cmd);
                if (!is_array($query))
                    $query = array($query);
                foreach ($query as $q)
                    $this->queries[] = $q;
            }
        }
    }
534809
public function hasPrimaryKey()
    {
        $empty = true;

        foreach ($this->keys as $key) {
            $empty = $empty && !$this->$key;
        }

        return !$empty;
    }
767271
public function isForeignPrimaryKey()
    {
        $lfmap = $this->getLocalForeignMapping();
        $foreignTable = $this->getForeignTable();

        $foreignPKCols = array();
        foreach ($foreignTable->getPrimaryKey() as $fPKCol) {
            $foreignPKCols[] = $fPKCol->getName();
        }

        $foreignCols = array();
        foreach ($this->getLocalColumns() as $colName) {
            $foreignCols[] = $foreignTable->getColumn($lfmap[$colName])->getName();
        }

        return ((count($foreignPKCols) === count($foreignCols)) && !array_diff($foreignPKCols, $foreignCols));
    }
1062722
public function checkExistence()
    {
        if (empty($this->primaryKey)) {
            return false;
        }

        return static::find()->pk($this->primaryKey)->count() > 0;
    }
595551
function hasPrimaryKeyValues() {
		$pks = static::$_primaryKeys;
		if (!$pks)
			return false;

		foreach ($pks as &$pk)
			if ($this->$pk === null)
				return false;
		return true;
	}