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);
            }
        }
    }


Messages In This Thread
Help with multiple insert thats not working. - by El Forum - 05-22-2011, 07:50 PM
Help with multiple insert thats not working. - by El Forum - 05-24-2011, 02:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB