Deletions are not allowed unless they contain a where clause or a like clause

My request is

$shortlistpartners - array

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

Deletions are not allowed unless they contain a where clause or a like clause. the error is coming, tell me some solution.

+4
source share
2 answers

In fact, the CI method delete()returns an no where or limiterror:

From 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 think all you have to do is share files with delete:

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

You have enabled --safe-updatesthat does not allowDELETE without WHERE

--safe-updates ( --i-am-a-dummy, ). , , , DELETE FROM tbl_name, WHERE. . --safe-updates , . .

Doc

SET SQL_SAFE_UPDATES = 0; :

SET SQL_SAFE_UPDATES=0; 

TRUNCATE TABLE_NAME;, .

0

Source: https://habr.com/ru/post/1524245/


All Articles