bcit-ci / CodeIgniter

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
18.27k stars 7.6k forks source link

bug: codeigniter3 db->or_where_not_in(...) #6262

Open 973432436 opened 10 months ago

973432436 commented 10 months ago
<?php
class Test{

    public function abc(){
        $errLinks = $this->db
                    ->where( 'article_id', 240105 )
                    ->group_start()
                        ->where_not_in( 'link_url', [ 'https://test.com/battery/' ] )
                        ->or_where_not_in( 'link_keyword', [ 'difference between test abc and lithium battery', 'difference between test cde and lithium battery' ] )
                    ->group_end()
                    ->get( 'TestDB' )->result_array();
        print_r( [ $errLinks, $this->db->last_query() ] );
    }

}
?>

image

jamieburchell commented 10 months ago

This is due to the automatic escaping. You'd need to turn it off and escape the values manually.

->or_where_not_in( 'link_keyword', [ '\'difference between test abc and lithium battery\'', '\'difference between test cde and lithium battery\'' ], FALSE )