Answers for "codeigniter 4 query builder where or"

1

where group codeigniter

$this->db->select('*')->from('my_table')
        ->group_start()
                ->where('a', 'a')
                ->or_group_start()
                        ->where('b', 'b')
                        ->where('c', 'c')
                ->group_end()
        ->group_end()
        ->where('d', 'd')
->get();

// Generates:
// SELECT * FROM (`my_table`) WHERE ( `a` = 'a' OR ( `b` = 'b' AND `c` = 'c' ) ) AND `d` = 'd'
Posted by: Guest on October-05-2020
-1

codeigniter 4 query builder select

$builder->select('title, content, date');
$query = $builder->get();

// Executes: SELECT title, content, date FROM mytable
Posted by: Guest on December-16-2020
-2

codeigniter select for update

$table = "my_table";
$id = 1;
$update = ["status"=>"working"];
//Edit just above / if you don't need extra "where" clause
$query = $this->db->select()
            ->from($table)
            ->where('id', $id)
            ->get_compiled_select();
$data = $this->db->query("$query FOR UPDATE")->row_array();
$this->db->where('id', $data['id'])->update($table,$update);
Posted by: Guest on October-02-2020

Code answers related to "codeigniter 4 query builder where or"

Browse Popular Code Answers by Language