Ouzo\Model::__construct PHP Method

__construct() public method

Accepted parameters:
public __construct ( array $params )
$params array {
    public function __construct(array $params)
    {
        $this->_prepareParameters($params);
        $this->_modelDefinition = ModelDefinition::get(get_called_class(), $params);
        $primaryKeyName = $this->_modelDefinition->primaryKey;
        $attributes = $this->_modelDefinition->mergeWithDefaults($params['attributes'], $params['fields']);
        if (isset($attributes[$primaryKeyName]) && Strings::isBlank($attributes[$primaryKeyName])) {
            unset($attributes[$primaryKeyName]);
        }
        $this->_attributes = $this->filterAttributes($attributes);
        $this->_modifiedFields = array_keys($this->_attributes);
    }

Usage Example

Example #1
0
 public function __construct($attributes = [])
 {
     parent::__construct(['attributes' => $attributes, 'fields' => ['id', 'game_user_id', 'field', 'multiplier', 'round'], 'belongsTo' => ['game_user' => ['class' => 'GameUser', 'foreignKey' => 'game_user_id', 'referencedColumn' => 'id']]]);
 }
All Usage Examples Of Ouzo\Model::__construct