View Full Version : How to save data.store to mysql using php

19 Feb 2011, 11:32 AM
I have data view and a grid . I use Drag and drop from DataView to Grid. I want to save all Grid's rows at once with php scripts, but i don't know how to send grids.store to PHP and how to iterate it to insert row by row to mysql. Please HELP .

20 Feb 2011, 6:55 AM
If your store's proxy has a properly configured writer you can do a store.sync() to send data to the server.
About the PHP part, it depends on many things like your level of experience with it (you might want to begin here (http://www.php.net/manual/en/index.php)), are you using a server-side application framework (like Kohana (http://kohanaframework.org/) or CodeIgniter (http://codeigniter.com/)), etc...

Simplest theoretical build-from-scratch approach would be to define an ajax proxy (http://dev.sencha.com/deploy/ext-4.0-pr1/docs/api/Ext.data.AjaxProxy.html) for your store, call store.sync() when you want to upload your records, and then on the server-side decode your $_POST variable and decide what to do with its content.

20 Feb 2011, 7:24 AM
I have Json.store to load data for DataView store. Then i create empty data store for the grid.
With Drag And Drop from DataView I add rows to Grid . Then i want to save all records from Grid to mysql table. I just want to know how to send params Grid.Store to php script and how _POST['store'] to be parsed in PHP ?

20 Feb 2011, 7:28 AM
This way work. But i think that this is very bad programing practice .
Please show the smart way.

function SaveOrder(){

firstGridStore.update ;
var grid_rows =firstGridStore.getCount() ;
if(grid_rows > 0) {

// make all id from data selected become 1,2,3,4,5,.....

var id = '';
var br = '';
var price = '' ;

var i = 0;

for(i=0; i<grid_rows ; i++) {
id += firstGridStore.getAt(i).data.id;
br += firstGridStore.getAt(i).data.color;
price += firstGridStore.getAt(i).data.price;

if(i < (grid_rows - 1)) {
id += ','; br +=',' ; price +=',' ;

waitMsg: 'Please wait...',
url: 'order.php',
params: {
// task: "UPDATEPRES",
user_id: user.id,
suma: smetka,
art_id: id ,
broj: br ,
price: price