ssp
ssp copied to clipboard
this error LEFT JOIN
Does not work
<?php
// DB table to use
$table = 'usuario_vod';
// Table's primary key
$primaryKey = 'cve';
$columns = array(
array( 'db' => '`u`.`user`', 'dt' => 0, 'field' => 'user', 'as' => 'user' ),
array( 'db' => '`u`.`contrasenia`', 'dt' => 1, 'field' => 'contrasenia' ),
array( 'db' => '`u`.`pin`', 'dt' => 2, 'field' => 'pin' ),
array( 'db' => '`u`.`status`', 'dt' => 3, 'field' => 'status'),
array( 'db' => '`ud`.`user`', 'dt' => 4, 'field' => 'user', 'as' => 'user' ),
array( 'db' => '`u`.`fecha_vencimiento`', 'dt' => 5, 'field' => 'fecha_vencimiento', 'formatter' => function( $d, $row ) {
return date( 'd-M-Y', strtotime($d));
}),
array('db' => '`u`.`idu_dispositivo`', 'dt' => 6, 'field' => 'idu_dispositivo'),
array('db' => '`u`.`idu_dispositivo`', 'dt' => 7, 'field' => 'idu_dispositivo')
);
// SQL server connection information
require('config.php');
$sql_details = array(
'user' => $db_username,
'pass' => $db_password,
'db' => $db_name,
'host' => $db_host
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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( 'ssp.class.php' );
require('ssp.customized.class.php' );
$joinQuery = "FROM `usuario_vod` AS `u` JOIN `usuario` AS `ud` ON (`ud`.`cve` = `u`.`cve_dealer`)";
$extraWhere = "";
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere )
);
In the user fields I throw the same data since they use the same field the 2 tables
Replace Line 53 of ssp.customized.class.php
Original:
$row[ $column['dt'] ] = ($isJoin) ? $data[$i][ $columns[$j]['field'] ] : $data[$i][ $columns[$j]['db'] ];
Replace With:
$row[ $column['dt'] ] = ($isJoin) ? (isset($columns[$j]['as']) ? $data[$i][ $columns[$j]['as'] ] : $data[$i][ $columns[$j]['field'] ]) : $data[$i][ $columns[$j]['db'] ];
It would be better, if you can share your ERROR as well.
Thanks