JQGrid错误删除了最后一个记录



错误删除了php 5.5.9

的最后一个记录
colModel: [
    {
        name: '',
        formatter: 'actions',
        formatoptions: {
            keys: true,
            afterSave: function () {
                $('#table_grid').trigger('reloadGrid');
            }
        }
    }
],          
loadComplete:function(data)
{
    alert(data.records);
    //PHP 5.3.13  $responce->records = 0
    //PHP 5.5.9  error empty    
}

有什么问题,帮助

我使用jquery.jqgrid.min 5.2.0

<script type="text/javascript">
$(document).ready(function()
{
    $('#table').jqGrid(
    {
        mtype:'POST',
        datatype:'json',
        url:'data.php',
        editurl:'data.php',
        rowNum:50,
        pager:'#pager',
        colModel:[
            {name:'action',formatter:'actions',formatoptions:{keys:true,afterSave:function(){$('#table').trigger('reloadGrid');}}},
            {name:'name',editable:true}
        ],
        loadComplete:function(data)
        {
            if(data.records >= 0)//error if PHP 5.5.9
            { 
            }
            //If i use PHP 5.3.13 function returns 0 (deletes the last record)
            //If i use PHP 5.5.9 function nothing returns (Do not delete the last record)               
        }
    });
    $('#table').jqGrid('inlineNav','#pager',{edit:false,addtext:'ADD',savetext:'SAVE',canceltext:'CANCEL',addParams:{position:'last',addRowParams:{keys:true,aftersavefunc:function(){$('#table').trigger('reloadGrid');}}}});
});
</script> 
//reading data.php
$page = $_POST['page'];
$limit = $_POST['rows'];
$count = $db->query('SELECT COUNT(*) FROM siri')->fetchColumn();
if($count > 0){$total_pages = ceil($count/$limit);}else{$total_pages = 0;}
if($page > $total_pages){$page = $total_pages;}
$start = $limit*$page-$limit;
if($start < 0){$start = 0;}
$res = $db->query('SELECT id, name FROM siri LIMIT '.$start.', '.$limit);
$i=0;
while($row = $res->fetch(PDO::FETCH_ASSOC))
{
    $return->rows[$i]['id'] = $row['id'];
    $return->rows[$i]['cell'] = array('',$row['name']);
$i++;
}
$return->page = $page;
$return->total = $total_pages;
$return->records = $count;
echo json_encode($return);
//Deleting data.php 
$id = (int)$_POST['id'];
$db->exec('DELETE FROM siri WHERE id = '.$id);  

一切都有效,jqgrid很好

但是,如果我使用PHP 5.5.9

浏览器中的最后一个条目未删除

页面更新后,它消失了

要删除,我使用内联操作

但是,如果我使用PHP 5.3.13没有错误,那么一切都很好

我需要PHP 5.5.9非常非常

最新更新