Welcome Guest, Not a member yet? Register   Sign In
active record bug on update

Hi All,
I found that if I put null value in where clause,
It will update the whole table. This is very serious
It should return an error and not execute the command
which is what happens if you use sql update statement.

Here is an example.
$id = null;
  $_data = array( 'csu_id' => 20 );
  $this->db->where( 'sl_id', $id );
  $this->db->update( 'storefront_lead', $_data );
All rows will have csu_id = 20


[eluser]Michael Wales[/eluser]
This bug was documented here.

A few potential solutions were posted as well: here and here.

I think the jury is still out there as to whether this is actually a bug or not. You really should validate your data prior to performing any potentially destructive queries.

I disagree. If I run an sql query equivalent to this
it will just return an error. I expect this to behave the same.
If not you'd be better of using good old sql query.

Allowing an incomplete query to run is unacceptable.

Theme © iAndrew 2016 - Forum software by © MyBB