Welcome Guest, Not a member yet? Register   Sign In
[3.1.2] update_batch not work
#1

(This post was last modified: 12-05-2016, 08:21 PM by rodrigoprazim.)

Code:
$dataTotal = array(
  array(
      'id' => 1,
      'name' => 'house',
      'description' => 'this house'
  ),
  array(
      'id' => 2,
      'name' => 'car',
      'description' => 'black car'
  )
);

$this->function_model->updateData($dataTotal);

public function updateData($data=NULL){
   $this->db->update_batch('mytable',$data,'id');
}

// Produces:
// UPDATE `mytable` SET `name` = CASE
// WHEN `id` = THEN 'house'
// WHEN `id` = THEN 'car'
// ELSE `name` END,
// `description` = CASE
// WHEN `id` = THEN 'this house'
// WHEN `id` = THEN 'black car'
// ELSE `description` END
// WHERE `id` IN (,)

With the new update the system does not capture the value of index.
Reply
#2

Also having this problem after updating from 3.0.6 > 3.1.2.
Reply
#3

(10-31-2016, 08:51 AM)rodrigoprazim Wrote:
Code:
$dataTotal = array(
  array(
      'id' => 1,
      'name' => 'house',
      'description' => 'this house'
  ),
  array(
      'id' => 2,
      'name' => 'car',
      'description' => 'black car'
  )
);

$this->function_model->updateData($dataTotal);

public function updateData($data=NULL){
   $this->db->update_batch('mytable',$data,'id');
}

// Produces:
// UPDATE `mytable` SET `name` = CASE
// WHEN `id` = THEN 'house'
// WHEN `id` = THEN 'car'
// ELSE `name` END,
// `description` = CASE
// WHEN `id` = THEN 'this house'
// WHEN `id` = THEN 'black car'
// ELSE `description` END
// WHERE `id` IN (1,2)

With the new update the system does not capture the value of index.
Reply
#4

(This post was last modified: 11-02-2016, 04:41 AM by pgee.)

the issue can be resolved by reverting line 1918 of DB_query_builder
from:
if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $index)))
to:
if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $this->protect_identifiers($index))))

please push out a fix - my error log file from today was > 2000 lines its caused a few headaches over here...
Reply
#5

(11-02-2016, 04:23 AM)pgee Wrote: the issue can be resolved by reverting line 1918 of DB_query_builder
from:
if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $index)))
to:
if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $this->protect_identifiers($index))))

please push out a fix - my error log file from today was > 2000 lines its caused a few headaches over here...

Thanks for replying, pgee, but unfortunately I had to downgrade the version, 3.1.2 to 3.1.0, until I solved this problem.
Reply
#6

Please test with https://github.com/bcit-ci/CodeIgniter/c...ea583dd8d8
Reply
#7

(This post was last modified: 12-12-2016, 08:13 AM by rodrigoprazim.)

(12-12-2016, 05:21 AM)Narf Wrote: Please test with https://github.com/bcit-ci/CodeIgniter/c...ea583dd8d8

Thanks for reply.

Will version 3.1.3 come out with fixes?
Reply
#8

(12-12-2016, 08:05 AM)rodrigoprazim Wrote:
(12-12-2016, 05:21 AM)Narf Wrote: Please test with https://github.com/bcit-ci/CodeIgniter/c...ea583dd8d8

Thanks for reply.

Will version 3.1.3 come out with fixes?

Will you test the quoted commit?
Reply
#9

(12-12-2016, 09:57 AM)Narf Wrote:
(12-12-2016, 08:05 AM)rodrigoprazim Wrote:
(12-12-2016, 05:21 AM)Narf Wrote: Please test with https://github.com/bcit-ci/CodeIgniter/c...ea583dd8d8

Thanks for reply.

Will version 3.1.3 come out with fixes?

Will you test the quoted commit?

I already did the tests and it worked perfectly, thank you.

Now I'm waiting for version 3.1.3 to upgrade to the system.
Reply
#10

(This post was last modified: 12-29-2016, 07:08 PM by PaulD.)

@Narf

Thank you for fixing that. Much appreciated.

I just spent 2-3 hours scratching my head and thinking 'Why is that not working?'. I thought I was going mad, outputting everything, var_dumping everything, reading the docs again and again, it was telling me the where clause was not finding the id field and it was from a big complex form, with variable amounts of input fields and validation rules, and I was sure I must have been doing something daft.

Then I thought to check the forums, and here it is, bug already found and fixed. Thank you. You are a superstar! Updated the system database file to the latest on github and all is peaceful and wonderful with update_batch once again :-)

Best wishes,

Paul.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB