我的项目有暂存和实时环境。在暂存环境中我的代码工作正常,但在现场它不起作用。 (两台服务器都运行php 5.6)
我的问题是Datatables Editor后端脚本返回空白页面而没有错误。我已经测试过,如果我在DB中有少量记录(比如5-10条记录),那就是正确加载所有内容。
后端脚本:
<?php
include( "../classes/datatables/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'translate' )
->fields(
Field::inst( 'id' ),
Field::inst( 'alias' )->validator( 'Validate::notEmpty' ),
Field::inst( 'lv' ),
Field::inst( 'ru' ),
Field::inst( 'en' ),
Field::inst( 'translated' )
->setFormatter( function ( $val, $data, $opts ) {
return ! $val ? 0 : 1;
} )
)
->process( $_POST )
->json();
我错过了任何我不知道的php库,可能会出现什么问题?
答案 0 :(得分:1)
OMG!花了2天时间找到解决方案,需要将“charset = utf8”添加到dsn!
$sql_details = array(
"type" => "Mysql", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
"user" => DB_LOGIN, // Database user name
"pass" => DB_PASS, // Database password
"host" => DB_HOST, // Database host
"port" => 3306, // Database connection port (can be left empty for default)
"db" => DB_DB, // Database name
"dsn" => "charset=utf8" // PHP DSN extra information. Set as `charset=utf8` if you are using MySQL
);