• 技术文章 >后端开发 >php教程

    jqgrid报表报错

    2016-06-13 11:21:19原创420

    jqgrid表格报错
    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payments' in 'field list'


    require_once '../../../jq-config.php';
    // include the jqGrid Class
    require_once ABSPATH."php/jqGrid.php";
    // include the driver class
    require_once ABSPATH."php/jqGridPdo.php";
    // Connection to the server
    $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
    // Tell the db that we use utf-8
    $conn->query("SET NAMES utf8");

    // Create the jqGrid instance
    $grid = new jqGridRender($conn);
    // Write the SQL Query
    $grid->SelectCommand = 'SELECT id,order_id,payments-date FROM `sale_orders`';
    // set the ouput format to json
    $grid->dataType = 'json';
    // Let the grid create the model from SQL query
    $grid->setColModel();
    // Set the url from where we obtain the data
    $grid->setUrl('grid.php');
    // Set alternate background using altRows property
    $grid->setGridOptions(array(
    "rowNum"=>10,
    "sortname"=>"id",
    "altRows"=>true,
    "multiselect"=>true,
    "rowList"=>array(10,20,50),
    ));
    // Change some property of the field(s)
    $grid->setColProperty("id", array("label"=>"ID", "width"=>60));
    $grid->setColProperty("payments-date", array(
    "formatter"=>"date",
    "formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"m/d/Y")
    )
    );
    // Enjoy
    $grid->renderGrid('#grid','#pager',true, null, null, true,true);
    $conn = null;
    ?>



    ------解决方案--------------------
    字段名是 payments-date 吗?中间有减号?
    `payments-date`

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:nbsp grid gt the payments
    上一篇:php获取现阶段url路径的函数 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • PHP+Socket系列之实现客户端与服务端数据传输• PHP socket学习:带你做个简单的socket服务器• 一文详解PHP用流方式实现下载文件(附代码示例)• PHP原生类的总结分享• PHP反序列化入门总结(小白必看)
    1/1

    PHP中文网