Hello, I read some topic, in particular this, without solution for my work.
So, I've create a PHP Function (NAME: server_side_array) with this code:
The output is
Then in TABLE (Name articles_list) VIEW I add this DATA PROVIDER: {var.jsonde:data_joined}
The INDEX EVENT is this:
My questions is:
Thank you for your reply
So, I've create a PHP Function (NAME: server_side_array) with this code:
$table = 'xijhd_cf_product_data-2';
// Table's primary key
$primaryKey = 'cf_id';
$columns = array(
array( 'db' => 'cf_id','dt' => 'arr_cf_id' ),
array( 'db' => 'p_description','dt' => 'arr_p_description' ),
array( 'db' => 'p_lotto', 'dt' => 'arr_p_lotto' ),
array( 'db' => 'g_tag', 'dt' => 'arr_g_tag' ),
array( 'db' => 'created','dt' =>'arr_created',
'formatter' => function( $d, $row ) {
return date( 'd-m-Y', strtotime($d));
}
)
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => '*********',
'db' => 'generaphoto',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'vendor/DataTables/server-side/scripts/ssp.class.php' );
/*
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
*/
$jdata1 = SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns );
$jdata = json_encode($jdata1);
$this->set("data_joined", $jdata);
echo $jdata;
The output is
{"draw":0,"recordsTotal":386,"recordsFiltered":386,"data":[{[mark]"arr_cf_id":"233","arr_p_description":"2020-01-01_1021","arr_p_lotto":"YZJ30EM","arr_g_tag":"sub1","arr_created":"03-02-2020"[/mark]},{"arr_cf_id":"232","arr_p_description":"2020-01-01_1021","arr_p_lotto":"YZJ30EM","arr_g_tag":"sub1","arr_created":"03-02-2020"},{"arr_cf_id":"231","arr_p_description":"2020-01-01_1021","arr_p_lotto":"YZJ30EM","arr_g_tag":"sub1","arr_created":"03-02-2020"},{"arr_cf_id":"230","arr_p_description":"2020-01-01_1021","arr_p_lotto":"YZJ30EM","arr_g_tag":"sub1","arr_created":"01-01-2020"},......
Then in TABLE (Name articles_list) VIEW I add this DATA PROVIDER: {var.jsonde:data_joined}
The INDEX EVENT is this:
{fn:server_side_array}
{view:articles_list}
My questions is:
- Is correct till now my work?
- what code I need to add in COLUMN LIST of TABLE VIEW to view arr_cf_id / arr_p_description / arr_p_lotto fields?
Thank you for your reply