DboSource::defaultConditions PHP Method

defaultConditions() public method

If conditions are supplied then they will be returned. If a model doesn't exist and no conditions were provided either null or false will be returned based on what was input.
See also: DboSource::update()
See also: DboSource::conditions()
public defaultConditions ( Model $Model, string | array | boolean $conditions, boolean $useAlias = true ) : mixed
$Model Model The model to get conditions for.
$conditions string | array | boolean Array of conditions, conditions string, null or false. If an array of conditions, or string conditions those conditions will be returned. With other values the model's existence will be checked. If the model doesn't exist a null or false will be returned depending on the input value.
$useAlias boolean Use model aliases rather than table names when generating conditions
return mixed Either null, false, $conditions or an array of default conditions to use.
    public function defaultConditions(Model $Model, $conditions, $useAlias = true)
    {
        if (!empty($conditions)) {
            return $conditions;
        }
        $exists = $Model->exists();
        if (!$exists && ($conditions !== null || !empty($Model->__safeUpdateMode))) {
            return false;
        } elseif (!$exists) {
            return null;
        }
        $alias = $Model->alias;
        if (!$useAlias) {
            $alias = $this->fullTableName($Model, false);
        }
        return array("{$alias}.{$Model->primaryKey}" => $Model->getID());
    }
DboSource