Welcome Guest, Not a member yet? Register   Sign In
Error with CI 3.1.2
#1

New error popping up when upgraded to CI 3.1.2.

Code:
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'THEN '1109' ELSE `wopart_id` END, `qty` = CASE WHEN `wopart_id` = THEN '2' ELS' at line 2

UPDATE `WOPARTS` SET `wopart_id` = CASE WHEN `wopart_id` = THEN '1109' ELSE `wopart_id` END, `qty` = CASE WHEN `wopart_id` = THEN '2' ELSE `qty` END, `price` = CASE WHEN `wopart_id` = THEN '59.40' ELSE `price` END WHERE `wopart_id` IN()

Filename: models/Transaction_model.php

Line Number: 131

This is the section of Transaction_model in question. Nothing in the model changed but somehow the insert_batch function is not working right with the latest update. Any ideas?

Code:
$this->load->model('parts_model');
        if($this->input->post('woPartsEdit') ){
            $woPartsEdit = $this->input->post('woPartsEdit');
            if(isset($woPartsEdit['wopart_id'])){
                $update_data = array();
                foreach($woPartsEdit['wopart_id'] as $key => $val){
                    if(isset($woPartsEdit['qty'][$key]) && isset($woPartsEdit['price'][$key]) ){
                        $update = array();
                        $update['wopart_id'] = $val;
                        $update['qty'] = $woPartsEdit['qty'][$key];
                        $update['price'] = $woPartsEdit['price'][$key];
                        $update_data[] = $update;
                    }
                }
                if(count($update_data) > 0) $this->db->update_batch('WOPARTS', $update_data, 'wopart_id');
            }
        }
Reply
#2

I think I came across the same issue with update_batch. See https://github.com/bcit-ci/CodeIgniter/issues/4892
Reply
#3

(11-14-2016, 04:27 PM)ajdunn Wrote: I think I came across the same issue with update_batch. See https://github.com/bcit-ci/CodeIgniter/issues/4892

Hey THANK YOU! Made this change and it fixed the problem. Not sure if there are any other repercussions of this but I'm going to fly with it for now. For anyone else that runs across this:

system > database > DB_query_builder line 1918 change
Code:
            if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, $batch_size), $index)))

to

Code:
            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))))
Reply




Theme © iAndrew 2016 - Forum software by © MyBB