Results 1 to 9 of 9

Thread: Work in 4.0 but not update (db) in 4.1

  1. #1

    Default Work in 4.0 but not update (db) in 4.1

    Code:
    function showSeasonWin(){    
                Ext.onReady(function(){
                Ext.define('SeasonModel', {
                    extend: 'Ext.data.Model',
                    fields: [ ]
                });
                
                
                        var seasonstore = Ext.create('Ext.data.Store', {
                        autoLoad: false,
                        autoSync: false,
                        model: 'SeasonModel',
                        storeId: 'SeasonStoreID',
                        proxy: {
                            type: 'ajax',
                            url: 'config/db-vypiski.php',
                            actionMethods: {
                                        create : 'POST',
                                        read   : 'GET',
                                        update : 'POST',
                                        destroy: 'POST',
                                },
                                reader: {
                                    type: 'json',
                                    root: '',
                                },
                                writer: {
                                    type: 'json',
                                    root: '',
                                }
                        }
                });
    Code:
            Ext.grid.RowEditor.prototype.saveBtnText = '????????';            Ext.grid.RowEditor.prototype.cancelBtnText = '??????';
                    
                var RowEdit = Ext.create('Ext.grid.plugin.RowEditing', {
                    clicksToEdit: 2,
                    autoCancel: false,
                    listeners: {
                        beforeedit: function() {
                            Ext.TaskManager.stop(task_start);
                            },
                        cancelEdit: function() {
                            Ext.TaskManager.start(task_start);
                            }
                        }
                });    
                                                    
                RowEdit.on({
                  scope: this,
                  afteredit: function(add) {
                      Ext.TaskManager.start(task_start);
                      Ext.Ajax.request({
                      url   : 'config/db-vypiski.php',
                      waitMsg: '?????????? ?????????...',
                      method: 'POST',
                      params: {task_update:'add',
                                  f1: add.record.data.step_id,
                                  f2: add.record.data.real_timedate,
                                  f3: add.record.data.prep_timedate,
                                  f4: add.record.data.date_from,
                                  f5: add.record.data.content,
                                  f6: add.record.data.number_zakaz,
                                  f7: add.record.data.summa_oplaty,
                                  f8: add.record.data.summa_zakaza,
                                  f9: add.record.data.manager,
                                  f10: add.record.data.comments
                      },
                      success: function() {
                      seasonstore.load();
                
                        }
                    });
                  },
                });
    PHP code
    Code:
    <?php$db = "vypiski";
    $table = "_vypiski";
    $fr = "step_id";
    
    
    $link = mysql_connect("localhost", "root","") or die("Could not connect");
    mysql_select_db($db) or die("Could not select database");
    
    
    
    
    $task_create = $_POST['task_create'];
    $task_delete = $_POST['task_delete'];
    $task_update = $_POST['task_update'];
    $f1 = $_POST['f1'];
    $f2 = $_POST['f2'];
    $f3 = $_POST['f3'];
    $f4 = $_POST['f4'];
    $f5 = $_POST['f5'];
    $f6 = $_POST['f6'];
    $f7 = $_POST['f7'];
    $f8 = $_POST['f8'];
    $f9 = $_POST['f9'];
    $f10 = $_POST['f10'];
    $idx = $_POST['idx'];
    
    
    switch ($_SERVER["REQUEST_METHOD"])
    {
        case 'GET':
        
        $fields = array();
        $arr = array();
        
        $fields_query = mysql_query("describe $table");
        while($fobj = mysql_fetch_object($fields_query)) {
            $fobj->name = $fobj->Field;
            $fobj->header = $fobj->Field;
            $fobj->dataIndex = $fobj->Field;
            $fields[] = $fobj;
        }
        $rs = mysql_query("select * from $table");    
        while($obj = mysql_fetch_object($rs)) {
            $arr[] = $obj;
        }
        echo '{ metaData: { "root": "data", "fields" : ' . json_encode($fields) . '},"success":true, "data":' . json_encode($arr) . '}';
                 break;
            
        case 'POST':
            if($task_update=='add'){
            $a = "UPDATE $table set step_id = '$f1',real_timedate = '$f2',prep_timedate = '$f3',date_from = '$f4',content = '$f5',number_zakaz = '$f6',summa_oplaty = '$f7',summa_zakaza = '$f8',manager = '$f9',comments = '$f10' where step_id ='$f1'";
        
            if (mysql_query($a)) {
            echo "{success:true}";
            }
            else echo "{success:false}";
            }
        
            if($task_create=='add'){
            $mass = array();    
            $rss = mysql_query("select $fr from $table");    
            while ($obj = mysql_fetch_row($rss)) {
            $mass[] = $obj;
            }
            $i = array_pop($mass);
            $i = $i[0] + 1;
    //        echo $i;
            $a = "insert into $table value('$i',' ',' ','2010-10-10','?????','????? ??????','?????','?????','???????? ?????????','???????')";
            if (mysql_query($a)) {
            echo "{success:true}";
            }
            else echo "{success:false}";    
            }
    
    
            if($task_delete=='del'){
            $a = "DELETE FROM $table WHERE $fr = '$idx' LIMIT 1";
            if (mysql_query($a)) {
            echo "{success:true}";
            }
            else echo "{success1:false}";
            echo $f1;
            }
    
    
        break;
        default:
        break;
    }
    mysql_close();
    ?>
    in 4.0 all work fine. But in 4.1 not work update.

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    What do you mean by 'not work'? What actually happens?

    My guess would be that the update request is being made but the parameters are all missing. Try adding your fields in your model.

    Ideally something like this should probably be done by saving through the model's proxy and writer.

  3. #3

    Default

    Not post in db

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    Have you verified that parameters in your header are send in the same manner as you are looking for in your server?

    Example: sort is not send as an object. If your server is not seeing header params correctly, you will get syntax errors in your SQL call. Are there any errors in your response?

    Scott.

  5. #5

    Default

    There nothing error. I make grid record, delete grid record. But if i need change data in grid record, i have nothing. Data sent but not post in db. In extjs 4.0 it's work properly.


    task_greate add - yes (add new record in grid)
    task_delete del - yes (delete record)
    task_update ??? nothing This send data to json but not in db.

    For example i change data - 2012-07-02

    Безымянный.jpg
    But not have changes
    Attached Images Attached Images

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    You id is null? You may have to dig around a little, or provide more info.

    Scott.

  7. #7

    Default

    May be this is RowEdit error?

  8. #8
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    I would start by omitting all of your edit events and work back. I would then verify your server is receiving/sending as expected. This should be a basic operation.

    Scott.

  9. #9

    Default

    There all - test.zip
    in config change $table = "_vypiski"; to $table = "spr_season"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •