Welcome Guest, Not a member yet? Register   Sign In
Help with multiple insert thats not working.
#1

[eluser]debow[/eluser]
I’m using datagrid that has a save-selected option. However it’s only saving a single row when selected or if you select multiple it only saves the last row edited. Here is the update function. Am I doing something wrong?


From the view.
Code:
function updateEresults() {
            var sm = gridEresults.getSelectionModel();
            var sel = sm.getSelections();
            var data = '';
            for (i = 0; i<sel.length; i++) {
                data = data + sel[i].get('id') + ';'
                        + sel[i].get('name')
                        + ';' + sel[i].get('event')
                        + ';' + sel[i].get('result')
                        + ';' + sel[i].get('status')
                        + '||';
            }
            Ext.Ajax.request({
                url: BASE_URL + 'resultspullups/ext_update',
                method: 'POST',
                params: { postdata: data }
            });
            strEresults.load();
        }

From the controller.
Code:
public function ext_update() {

        $records = explode('||', $_POST['postdata']);

        foreach ($records as $row) {
            $field = explode(';', $row);

            $data = array(
                'name' => $field[1],
                'event' => $field[2],
                'result' => $field[3],
                'status' => $field[4]
            );

            if (is_numeric($field[0])) {
                $this->db->where('id', $field[0]);
                $this->db->update('pullup_results', $data);
                
            } else {
                $this->db->insert('pullup_results', $data);
            }
        }
    }
#2

[eluser]debow[/eluser]
I'm not getting much help but thought I'd add this. I got this from firebug. Looks like the post of single or multi select's is making it to the update function so something else is happening keeping it from updating more then one row.

[code]
Parametersapplication/x-www-form-urlencoded
postdata 8;John Doe;100m Swim;1;12.40;01:12:40;active||
Source
postdata=8;John Doe;100m Swim;1;12.40;01:12:40;active||


Parametersapplication/x-www-form-urlencoded
postdata 12;Jane Doe;100m Swim;1;55.00;01:55:00;active||8;John Doe;100m Swim;1;12.40;02:12:40;active||
Source
postdata=12;Jane Doe;100m Swim;1;55.00;01:55:00;active||8;John Doe;100m Swim;1;12.40;02:12:40;active||
[/cod]




Theme © iAndrew 2016 - Forum software by © MyBB