yii\db\ActiveRecordInterface::getPrimaryKey PHP Метод

getPrimaryKey() публичный Метод

Returns the primary key value(s).
public getPrimaryKey ( boolean $asArray = false ) : mixed
$asArray boolean whether to return the primary key value as an array. If true, the return value will be an array with attribute names as keys and attribute values as values. Note that for composite primary keys, an array will always be returned regardless of this parameter value.
Результат mixed the primary key value. An array (attribute name => attribute 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`).
    public function getPrimaryKey($asArray = false);

Usage Example

Пример #1
0
 /**
  * Get variation models for the main one in batches.
  * @param Model|ActiveRecordInterface $model main model instance.
  * @return array list of variation models in format: behaviorName => Model[]
  */
 protected function getVariationModelBatches($model)
 {
     $key = serialize($model->getPrimaryKey());
     if (!isset($this->_variationModelBatches[$key])) {
         $this->_variationModelBatches[$key] = $this->findVariationModelBatches($model);
     }
     return $this->_variationModelBatches[$key];
 }
All Usage Examples Of yii\db\ActiveRecordInterface::getPrimaryKey