Codeigniter's `where` and `or_where`

前端 未结 5 1685
旧时难觅i
旧时难觅i 2020-12-09 03:41

I\'m trying to specify a query in my model

$this->db
        ->select(\'*\')
        ->from(\'library\')
        ->where(\'library.rating >=\'         


        
5条回答
  •  一个人的身影
    2020-12-09 04:12

    You may group your library.available_until wheres area by grouping method of Codeigniter for without disable escaping where clauses.

    $this->db
        ->select('*')
        ->from('library')
        ->where('library.rating >=', $form['slider'])
        ->where('library.votes >=', '1000')
        ->where('library.language !=', 'German')
        ->group_start() //this will start grouping
        ->where('library.available_until >=', date("Y-m-d H:i:s"))
        ->or_where('library.available_until =', "00-00-00 00:00:00")
        ->group_end() //this will end grouping
        ->where('library.release_year >=', $year_start)
        ->where('library.release_year <=', $year_end)
        ->join('rating_repo', 'library.id = rating_repo.id')
    

    Reference: https://www.codeigniter.com/userguide3/database/query_builder.html#query-grouping

提交回复
热议问题