CodeIgniter Forums
[3.1.2] update_batch not work - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: Issues (https://forum.codeigniter.com/forum-19.html)
+--- Thread: [3.1.2] update_batch not work (/thread-66522.html)

Pages: 1 2


[3.1.2] update_batch not work - rodrigoprazim - 10-31-2016

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.


RE: [3.1.2] update_batch not work - JarredB - 10-31-2016

Also having this problem after updating from 3.0.6 > 3.1.2.


RE: [3.1.2] update_batch not work - pgee - 11-02-2016

(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.



RE: [3.1.2] update_batch not work - pgee - 11-02-2016

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...


RE: [3.1.2] update_batch not work - rodrigoprazim - 11-08-2016

(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.


RE: [3.1.2] update_batch not work - Narf - 12-12-2016

Please test with https://github.com/bcit-ci/CodeIgniter/commit/8338bbb3586e31432caa503b6530dcea583dd8d8


RE: [3.1.2] update_batch not work - rodrigoprazim - 12-12-2016

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

Thanks for reply.

Will version 3.1.3 come out with fixes?


RE: [3.1.2] update_batch not work - Narf - 12-12-2016

(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/commit/8338bbb3586e31432caa503b6530dcea583dd8d8

Thanks for reply.

Will version 3.1.3 come out with fixes?

Will you test the quoted commit?


RE: [3.1.2] update_batch not work - rodrigoprazim - 12-15-2016

(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/commit/8338bbb3586e31432caa503b6530dcea583dd8d8

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.


RE: [3.1.2] update_batch not work - PaulD - 12-29-2016

@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.