logo
down
shadow

codeigniter multiple where clause is not working


codeigniter multiple where clause is not working

By : icevita
Date : November 21 2020, 11:01 PM
This might help you My controller (I want to select records based on some conditions) : , [SOLVED]. Use where_in() instead of or_where
code :


Share : facebook icon twitter icon
Codeigniter where clause is not working

Codeigniter where clause is not working


By : usernameexp
Date : March 29 2020, 07:55 AM
wish of those help I'm new to codeigniter I've a function in model with this code , Try Like this:
code :
$where = array('username' => $username, 'password' => $password, 'status' => '1');

$this->db->where($where); 
or_where clause not working in codeigniter

or_where clause not working in codeigniter


By : Appliance repair Ana
Date : March 29 2020, 07:55 AM
Any of those help You cannot use multiple where and or_where like you have used.
If your CI version is 3 or above, then you can use query-grouping function to achieve this. check this link https://codeigniter.com/user_guide/database/query_builder.html#query-grouping
Codeigniter db query clause where not working

Codeigniter db query clause where not working


By : Taciturn
Date : March 29 2020, 07:55 AM
hope this fix your issue I built a query: , you need to add group_start() and group_end().like this.
code :
 if (!empty($search)) {
      $this->db->group_start();
        $this->db->like('name', $search);
        $this->db->or_like('last_name', $search);
        $this->db->or_like('phone_number', $search);
        $this->db->or_like('created_at', $search);
        $this->db->or_like('note', $search);
        ->group_end();
    }
Codeigniter Where clause not working

Codeigniter Where clause not working


By : enav
Date : March 29 2020, 07:55 AM
Hope this helps Codeigniter Where clause does not work while use Variable. If I use number directly for $price_min this should be work. , Hope this will work for you:
code :
function filter()
{      
    $state = $this->input->post("state");
    $type = $this->input->post('type');
    $bed = $this->input->post('bed');
    $bath = $this->input->post('bath');

    $price_min = $this->input->post("price-min");
    $price_max = $this->input->post("price-max");

    /*you can set 0 or whatever if post is empty i set null */
    $price_min = ! empty($price_min) ? intval($price_min) : NULL;
    $price_max = ! empty($price_max) ? intval($price_max) : NULL;

    /* you can also check with if statement
       if ($price_min != '' && $price_max != '') {
          $price_max  = intval($price_max);
          $price_min = intval($price_min);
          your where statement.....
       }
    */
    $this->db->where('prize >' , $price_min);
    $this->db->where('prize <' , $price_max);

    $filterquery = $this->db->get('details');
    $records = $filterquery->result();
    return array(
        'records' => $records,
        'count' => count($records),
    );
}
where clause for datatable in codeigniter not working

where clause for datatable in codeigniter not working


By : Sven Bauermann
Date : March 29 2020, 07:55 AM
Any of those help I'm trying to make simple datatable, It's completely okay with out the where clues but I need the where clue to work "$this->db->where('user.user_id', $this->session->userdata('user_id'));". Please help me to fine out whats going wrong here. , Your where clause is not working because you have used OR like
code :
$this->db->or_like(`"content", $_POST["search"]["value"]`);
        if (isset($_POST["search"]["value"])){
            $this->db->group_start();
            $this->db->like("login", $_POST["search"]["value"]);
            $this->db->or_like("content", $_POST["search"]["value"]);
            $this->db->group_end();
        }
$this->db->last_query();
shadow
Privacy Policy - Terms - Contact Us © soohba.com