j4mie / idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.
http://j4mie.github.com/idiormandparis/
2.01k stars 369 forks source link

More then one where_raw #236

Closed onlysli closed 7 years ago

onlysli commented 10 years ago

Hi, It seems that i can't use more then one where_raw in one statement. Only the first one is working, the second one is ignored.

Is there a fix for this?

Thank you!

treffynnon commented 10 years ago

Please include the code you're using.

onlysli commented 10 years ago

I have to filters:

//filter url
public static function url($orm, $url) {
        return $orm->where_raw('( `url_rewrite` = ? ) OR ( `url_rewrite_en` = ? )', array($url, $url));
}

//filter visible
public static function visibles($orm) {
        return $orm->where('trash', 0)->where('activ', 1)
        ->where_raw('(( DATE(`start_date`) <= ? ) AND ((`end_date` != ? AND DATE(`end_date`) >= ?) OR (`end_date` = ? OR `end_date` = \'\')))', array(date("Y-m-d"), '0000-00-00', date("Y-m-d"), '0000-00-00'));
 }

and used together:

$spot = Model::factory('Spots')->filter('url', $this->principal_arguments)->filter('visibles')->find_one();

Will ignore second filter.

I also tried to use the where_row directly without filters but same effect.

Thank you.

treffynnon commented 7 years ago

I have written a test to verify this and I cannot replicate the issue you're having. Please see https://github.com/j4mie/idiorm/blob/develop/test/QueryBuilderTest.php#L295

If you run the test suite and still get failures please open a new ticket.