dongleibeng5602 2015-10-30 17:08
浏览 84
已采纳

php-mysql数据表与Datatable Server处理ssp.class.php脚本

I am trying to create a data grid using [Datatables][1] Jquery plugin and process it on the server using provided ssp.class.php. It did work but i ran into problem when i want to fetch data from multiple tables. I used The modified form created by emram. I have followed the steps and am still getting error like (invalid string offset 0) and the same class seemed to be working people. Here is my code.

<?php

$table ="property";
        $primaryKey = 'property.propertyID';

// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
       /* $columns = array(
            array( 'db' => 'propertyNAme', 'dt' => 0 ),
            array( 'db' => 'propertyAddress',  'dt' => 1 ),
            array( 'db' => 'propertyCode',   'dt' => 2 ),
            array( 'db' => 'propertyRegistrationNumber',     'dt' => 3 ),
            array( 'db'   => 'createdAt','dt' => 4,'formatter' => function( $d, $row ) {return date( 'jS M y', strtotime($d)); }),
            array('db'  => 'propertyPrice', 'dt'=> 5,'formatter' => function( $d, $row ) { return '$'.number_format($d); } )
        );*/
        $sql_details = array(
            'user' =>APP_SYSTEM_DB_USER_NAME,
            'pass' => APP_SYSTEM_DB_USER_PASSWORD,
            'db'   => APP_SYSTEM_DB_NAME,
            'host' => APP_SYSTEM_DB_HOST
        );
        $columns = array(
            array( 'db' => 'p.propertyName',    'dt' => 0, 'field' => 'Property Name' ),
            array( 'db' => 'p.propertyAddress',  'dt' => 1, 'field' => 'Address' ),
            array( 'db' => 'p.propertyCode',        'dt' => 2, 'field' => 'Property Code' ),
            array( 'db' => 'p.propertyRegistrationNumber',  'dt' => 3, 'field' => 'Reg No'),
            array( 'db' => 'p.propertyPrice',           'dt' => 4, 'field' => 'email' ),
            array( 'db' => 'p.createdAt', 'dt' =>5,'field' => 'date','formatter' => function( $d, $row ) {return date( 'jS M y', strtotime($d)); }),
            array( 'db' => 'c.countryName',             'dt' => 6, 'field' => 'Country'));
        $joinQuery = " FROM `{$table}` AS p LEFT JOIN country AS c ON (c.countryID = p.propertyCountryID)";
        $extraWhere="";
           $data= \app\models\datatable\helper\SSP::simple($_GET, $sql_details,$table, $primaryKey, $columns,$joinQuery, $extraWhere);
echo json_encode($data)

</div>
  • 写回答

1条回答 默认 最新

  • douyin7829 2015-11-03 10:49
    关注

    Thanks!. I have figured it out my self. I was sanitizing my $_GET variables before calling

    $_GET =$validator->sanitize($_GET)->xss_clean($_GET); 
    SSP::simple($_GET...)

    I just commented this code out and it worked
    . It works now –

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了