Open gidzr opened 2 weeks ago
Think you have the usage incorrect.
set_update_batch($key[, $value = ''[, $escape = NULL]])
Note that the second parameter isn't for an index column to be specified but for a single value in the case where $key
is a single field.
$key
(mixed) – Field name or an array of field/value pairs$value
(string) – Field value, if $key
is a single field$escape
(bool) – Whether to escape values and identifiersupdate_batch()
The first parameter will contain the table name, the second is an associative array of values, the third parameter is the where key.
So you probably need to specify your index column in the third parameter of update_batch()
.
Try:
$this->db->set_update_batch($dataArrBatch)->update_batch('table_name', NULL, 'index_col');
Or
$this->db->update_batch('table_name', $dataArrBatch, 'index_col');
https://www.codeigniter.com/userguide3/database/query_builder.html
@narfbg
I think this is a bug.
To recreate:
$this->db->set_update_batch($dataArrBatch,'index_col')->update_batch('table_name');
Gives error:
"You must specify an index to match on for batch updates."
Hypothesis:
The index parameter in the set_update_batch() function is not parsing to the ->update_batch function
Disclaimer:
Maybe I've completely overlooked the correct usage and assumed the wrong behaviours.. so if that's the case I apologise in advance.
My workaround / patch:
OLD VERSION
PATCHED VERSION
OLD VERSION
PATCHED VERSION
ps. I love CI-3.. query builder is awesome.. I am not moving to CI4 because all I need is simple MVC classes, awesome query builder, simple global post retriever, simple DB integration and I've also customised the query builder for JSON functions. I don't need any other bells and whistles like form validation, front-end stuff, etc. I feel that the power of a php framework is the framework / architecture / security / extensibility, .. it just needs to accommodate and stack other tech and take care of cyber threats.