framework/db/BaseActiveRecord.php
public function getPrimaryKey($asArray = false)
    {
        $keys = $this->primaryKey();
        if (!$asArray && count($keys) === 1) {
            return isset($this->_attributes[$keys[0]]) ? $this->_attributes[$keys[0]] : null;
        }

        $values = [];
        foreach ($keys as $name) {
            $values[$name] = isset($this->_attributes[$name]) ? $this->_attributes[$name] : null;
        }

        return $values;
    }
public function getPrimaryKey($asArray = false)
    {
        $keys = $this->primaryKey();
        if (!$asArray && count($keys) === 1) {
            return isset($this->_attributes[$keys[0]]) ? $this->_attributes[$keys[0]] : null;
        }

        $values = [];
        foreach ($keys as $name) {
            $values[$name] = isset($this->_attributes[$name]) ? $this->_attributes[$name] : null;
        }

        return $values;
    }
Returns the primary key value(s).
@param bool $asArray whether to return the primary key value as an array. If `true`,
the return value will be an array with column names as keys and column values as values.
Note that for composite primary keys, an array will always be returned regardless of this parameter value.
@property mixed The primary key value. An array (column name => column value) is returned if
the primary key is composite. A string is returned otherwise (null will be returned if
the key value is null).
@return mixed the primary key value. An array (column name => column value) is returned if the primary key
is composite or `$asArray` is `true`. A string is returned otherwise (null will be returned if
the key value is null).