I'm getting some unexpected behaviour using a BETWEEN predicate in ZF2. Consider the following code:
$ranges = array(
array(
'min' => 2,
'max' => 4
),
array(
'min' => 7,
'max' => 9
)
);
$predicates = array();
foreach($ranges as $range){
// create a new 'Between' predicate and add it to array
$between = new Predicate\Between('my_field', $range['min'], $range['max']);
array_push($predicates, $between);
}
// add predicateset
$select->where->addPredicate(
new Predicate\PredicateSet(
$predicates,
Predicate\PredicateSet::COMBINED_BY_OR
)
);
Now all of this works fine, except when using a range including 1
(eg. 0-2
, 1-5
etc).
In that case the resultset also includes values of 10
However, this does not happen when I try something like the query below directy on the DB:
SELECT * FROM my_table WHERE my_field BETWEEN 0 AND 5
(my_field
is a varchar
in this case)
What am I missing here?