1

I have a problem using this custom ssp file , I use jOIN statement then I saw this repository in GIT , then I try to follow it, then I already done with it but no output show. what's wrong with my code?

I forgot to indicate the source of this algorithm >> https://github.com/emran/ssp/blob/master/example/scripts/ssp.customized.class.php

UPDATE: I already get the DATA but the sorting,searching,pagination are not working. what do I need to do ?

$table = 'documentlog';
$primaryKey = 'logid';
$columns = array(
array( 'db' => '`a`.`ts`'               ,'dt' => 0, 'field' => 'ts' ),
array( 'db' => '`d`.`barcodenumber`'    ,'dt' => 1, 'field' => 'barcodenumber'),
array( 'db' => '`a`.`remarks`'          ,'dt' => 2, 'field' => 'remarks' ),
array( 'db' => '`c`.`department`'       ,'dt' => 3, 'field' => 'department' ),
array( 'db' => '`a`.`ts`'               ,'dt' => 4, 'field' => 'ts', 'formatter' => function( $d, $row ) 
{ 
    $date1 = date_create($d);
    $date2 = date_create(date('Y-m-d H:i:s'));
    $dd = date_diff($date1, $date2);
    $diff = $dd->y."years,".$dd->m."months,".$dd->d."days";
    return $diff;
})
);

$sql_details = array(
'user' => 'root',
'pass' => '',
'db'   => 'db_name',
'host' => 'localhost'
);

require( 'ssp.php' ); (I rename the file to ssp.php)

$joinQuery  = " FROM `documentlog` AS `a` INNER JOIN `sub_query` AS `b` ON (`b`.`docid` = `a`.`docid` AND `b`.`logid`=`a`.`logid` ) INNER JOIN `user` AS `c` ON (`c`.`uid` = `a`.`user` ) INNER JOIN `document` `d` ON (`d`.`id` = `a`.`docid`) ";

$extraWhere = " `c`.`department` = '".$sample."' AND `d`.`end` = 0"; 

echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere, $groupBy)
);

And my script is :

$(document).ready(function(){
                    var table = $('#tbl_doc_rec').DataTable({
                        "processing": true,
                        "serverSide": true,
                        "ajax" : {url:'back_end.php', type:'POST'},
                        });
                        });
koroku
  • 23
  • 6
  • If you have a situation of 'no output show' you should investigate. Are there any obvious PHP errors, either in the output of in the logs? – KIKO Software Oct 11 '18 at 07:43
  • @KIKOSoftware no error in console, just this: data[]: draw: 0 , recordsFiltered: 0, recordsTotal: 2802177 – koroku Oct 11 '18 at 07:51
  • And what do you see when you run the query against the database directly? For instance with PHPMyAdmin. – KIKO Software Oct 11 '18 at 08:56
  • @KIKOSoftware a exact output that I want to show. it's working but when I contruct it like what I posted , it not working – koroku Oct 12 '18 at 00:32

0 Answers0