This method allow your model to add various WHERE conditions before your get, search or find call.
However it uses a new way of define your conditions and keep ALL compatibility when database change.
@param String $condition_start
@param String $stringOperator
@param String/Integer $conditon_end
@param String $condition
@param Boolean $override
@return PhpBURN_Core
Params
$condition_start
What will match.
Usualy a field but you can match ANYTHING
$stringOperator
The operator of the match
$conditon_end
What will match with $condition_start
$condition (optional)
By default $condition is equal “AND” that means you can cascade various wheres without worry about putting AND but if you and to change it just fill this OPTIONAL field.
$override (optional)
Clean others $model->where(…) seted before this and starts again.
Explanation
You can use this method leting it be 100% compatible with all databases, that means if one day you boss wake up and say: Let’s migrate to Oracle because IBM uses it you will not be arrested because you try to kill him you will smile and say: Right the way
Example:
$user = new Users();
$user->where('last_name','=','Smith');
$user->find();
while($user->fetch()) {
print_r($user->toArray());
}
BUT if you need for ANY REASON use a string instead ( may not be compatible with all databases if you use a non ASCII function or sintax ) you can do:
$user = new Users();
$user->where('users.last_name = "Smith"');
$user->find();
while($user->fetch()) {
print_r($user->toArray());
}
And it will produce the same effect.
This method is FLUID it means that returns it’s same model ( PhpBURN_Core ) so you can use like this:
$user = new Users();
$user->where('last_name','=','Smith')
->where('id_user','>=',10)
->where('gender','=','male')
->find();
while($user->fetch()) {
print_r($user->toArray());
}
So, be creative…
