0

我正在尝试使用 [Datatables][1] Jquery 插件创建一个数据网格,并使用提供的ssp.class.php在服务器上对其进行处理。它确实有效,但是当我想从多个表中获取数据时遇到了问题。我使用了 emram 创建的修改后的表格。我已按照这些步骤操作,但仍然遇到错误,例如(无效的字符串偏移量 0),并且同一个班级似乎是工作人员。这是我的代码。

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

4

1 回答 1

0

谢谢!。我已经弄清楚了我自己。在调用之前我正在清理我的 $_GET 变量

$_GET =$validator->sanitize($_GET)->xss_clean($_GET); 
SSP::simple($_GET...)
我只是把这段代码注释掉了,它起作用了。现在可以使用了——</p>
于 2015-11-03T10:49:33.360 回答