Controller_Data_SQL::updateConditions PHP Method

updateConditions() public method

public updateConditions ( $model, $dsql )
    public function updateConditions($model, $dsql)
    {
        foreach ($model->conditions as $cond) {
            if ($cond[0] instanceof DB_dsql) {
                $dsql->where($cond[0]);
                continue;
            }
            $field = $model->getElement($cond[0]);
            if (!$field instanceof Field_Base) {
                throw $this->exception('Field not found')->addMoreInfo('field', $field);
            }
            if ($field->type() === 'boolean') {
                $cond[2] = $field->getBooleanValue($cond[2]);
            }
            if ($cond[1] === '=') {
                $field->defaultValue($cond[2])->system(true)->editable(false);
                // ???
            }
            $fieldName = $field->short_name;
            if ($field instanceof Field_SQL_Expression) {
                // TODO: should we use expression in where?
                $dsql->where($field->getExpression(), $cond[1], $cond[2]);
            } else {
                $dsql->where(($field->table() ?: ($model->table_alias ?: $model->table)) . '.' . $fieldName, $cond[1], $cond[2]);
            }
        }
    }