Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deletes are not allowed unless they contain a "where" or "like" clause

My Query-

$shortlistpartners is array

$this->db->delete('shortlist_partners');
$this->db->where('opp_id',$this->input->post('opp_id'));
$this->db->where_in('partner_id',$shortlistpartners);

Deletes are not allowed unless they contain a "where" or "like" clause. error is coming,tell me any solution.

like image 687
Reena Shirale Avatar asked Oct 20 '22 15:10

Reena Shirale


1 Answers

Actually, CI delete() method returns no where or limit error on:

From the Source Code:

if (count($this->ar_where) == 0 && count($this->ar_wherein) == 0 && count($this->ar_like) == 0)
{
    if ($this->db_debug)
    {
        return $this->display_error('db_del_must_use_where');
    }

    return FALSE;
}

So I guess all you need to do is to swap your wheres with delete call:

$this->db->where('opp_id',$this->input->post('opp_id'));
$this->db->where_in('partner_id',$shortlistpartners);
$this->db->delete('shortlist_partners');   
like image 58
Eternal1 Avatar answered Oct 27 '22 08:10

Eternal1