php-mysql 具有数据表服务器处理的数据表 ssp.class.php 脚本

php-mysql datatables with Datatable Server processing ssp.class.php Script

我正在尝试使用 [Datatables][1] Jquery 插件创建数据网格,并使用由 emram 创建的 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 在服务器上处理它。我已经按照这些步骤操作,但仍然收到类似(无效的字符串偏移量 0)的错误,并且 class 似乎是工作人员。这是我的代码。

<?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)

谢谢!我自己弄明白了。我在调用

之前清理了我的 $_GET 变量

$_GET =$validator->sanitize($_GET)->xss_clean($_GET); 
SSP::simple($_GET...)
我刚刚注释掉这段代码并且它起作用了 .现在可以使用了 –