Codeigniter 3: Batch update update_batch()

Asked

Viewed 153 times

0

I need to batch update a table, I have an object called $data as the example below:

Array
(
    [0] => stdClass Object
        (
            [nota] => 
            [frequencia] => 
            [temaTcc] => 
            [idNotaFreq] => 3416a75f4cea9109507cacd8e2f2aefc
        )

    [1] => stdClass Object
        (
            [nota] => 
            [frequencia] => 
            [temaTcc] => 
            [idNotaFreq] => a1d0c6e83f027327d8461063f4ac58a6
        )

    [2] => stdClass Object
        (
            [nota] => 
            [frequencia] => 
            [temaTcc] => 
            [idNotaFreq] => 17e62166fc8586dfa4d1bc0e1742c08b
        )
)

I’ll make the call on update_batch() as follows:

return $this->db->update_batch($table, $data, 'md5(idNotaFreq)');

Error message I get:

One or more rows sent for batch update is missing the specified index(index).
Filename: C:/xampp/htdocs/cert_emissao/system/database/Db_query_builder.php Line Number: 2028

Note: In the example I left only 3 positions of the object, and I know that they are with some empty attributes, but I tried to fill all and even so persisted the problem. The objects I send to update has between 10 and 14 positions in total, with a chance of some attributes being empty (as the example above) or can all be filled in. However, I always have the key filled in idNotaFreq which I believe cannot be empty. The table name is nota_freq (Mysql).

  • Are the values of this table mandatory? ie, nota and/or frequencia and/or temaTcc there is some rule in the bank that may or may not be recorded?

  • None of the 3 are mandatory.

  • I was able to "solve" by making a change. I passed idNotaFreq in the WHERE clause on md5(). I removed md5() and it worked.

  • Does update_batch() not even work with md5(), or did I do it wrong? With update() md5() usage normally.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.