[eluser]JustinWyllie[/eluser]
Code:
//in config/database.php
$db['default']['db_debug'] = FALSE;
Code:
create table test (
keyid int not null auto_increment primary key,
field varchar(255)
);
insert into test values(null, 'test1');
Code:
//field name is wrong; result is no change to db, no response output as expected.
$test = array(
array('keyid'=>1, 'fieldXXX'=>'test2')
);
$this->db->trans_start();
$this->db->update_batch('test', $test, 'keyid');
$this->db->trans_complete();
Code:
// name of key field for update is wrong; result is no change to db, get the Standard
//Database error page with 'One or more rows submitted for batch updating
//is missing the specified index.'
$test = array(
array('keyidXXX'=>1, 'field'=>'test2')
);
$this->db->trans_start();
$this->db->update_batch('test', $test, 'keyid');
$this->db->trans_complete();
I think it is totally trivial.
What is actually happening is this:
in system/database/DB_active_rec.php update_batch() calls set_update_batch() to set up the keys for the update. set_update_batch() has a little routine which sets keys/values. It finds that the there is no index in the data array matching the 3rd param originally passed to update_batch and produces an error:
Code:
if ($index_set == FALSE)
{
return $this->display_error('db_batch_missing_index');
}
There is no check for :
Code:
if ($this->db_debug)
hence an error whatever the db config setting.
If there was a check for db_debug and if it was allowed to continue without an error $ar_set would not be set and in update_batch the check for an empty array $this->ar_set would work and update_batch() would return false.
So it looks like there is a fix to be made here:
in function set_update_batch():
Code:
//add check for db_debug and only set ar_set if it can be set
if (($index_set == FALSE) )
{
if ($this->db_debug) {
return $this->display_error('db_batch_missing_index');
}
}
else
{
$this->ar_set[] = $clean;
}
It would need someome to check that over I think.
--Justin