Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82273

Search don't work anymore (serverside)

$
0
0

Hi,

I use DataTable for about 2 week (so good tool). I use the server side with a ssp class customized (https://emranulhadi.wordpress.com/2014/06/05/join-and-extra-condition-support-at-datatables-library-ssp-class/) because I have understood the initial ssp class can't do multiple join. If I am wrong do not hesitate to tell me !

Recently, I am not able anymore to search in my database. No error returned. The entire table is returned and I don't understand why...

I have used datatable debugger here : http://debug.datatables.net/oyazek

Here is my php code. I do not have modified my ssp.class.custo.php.

If anyone has an idea why Datatable return the all datatabase, he's welcome ! :)

<?php
 
/*
 * DataTables example server-side processing script.
 *
 * Please note that this script is intentionally extremely simply to show how
 * server-side processing can be implemented, and probably shouldn't be used as
 * the basis for a large complex system. It is suitable for simple use cases as
 * for learning.
 *
 * See http://datatables.net/usage/server-side for full details on the server-
 * side processing requirements of DataTables.
 *
 * @license MIT - http://datatables.net/license_mit
 */
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Easy set variables
 */

// DB table to use
$table = 'tab_remarks';
 
// Table's primary key !! NEED A PRIMARY KEY IN THE DATATABLE !! 
$primaryKey = 'id';

$archived = $_POST['archived'];

$language = 'fr';
 

// 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 (is sent in the array). In this case simple
// indexes. 'Field' is the field name in the target database.
$columns = array(
    array( 'db' => '`rem`.`id`',                               'dt' => 'id',            'field' => 'id'),
    array( 'db' => '`rem`.`name_doc`',                         'dt' => 'name_doc',      'field' => 'name_doc' ),
    array( 'db' => '`stat`.`stat_sn_' . $language . '`',       'dt' => 'status',        'field' => 'stat_sn_' . $language),
    array( 'db' => '`stat`.`id_status`',                       'dt' => 'id_stat',       'field' => 'id_status'),
    array( 'db' => '`doc`.`doc_sn_' . $language . '`',         'dt' => 'doc',           'field' => 'doc_sn_' . $language),
    array( 'db' => '`rem`.`remark`',                           'dt' => 'remark',        'field' => 'remark' ),
    array( 'db' => '`user`.`u_pseudo`',                        'dt' => 'user',          'field' => 'u_pseudo'),
    array( 'db' => '`rem`.`write_date`',                       'dt' => 'write_date',    'field' => 'write_date'),
    array( 'db' => '`rem`.`recieve_date`',                     'dt' => 'recieve_date',  'field' => 'recieve_date'),
    // Short name in the tech database
    array( 'db' => '`tech`.`tech_sn_' . $language . '`',       'dt' => 'technic',       'field' => 'tech_sn_' . $language),
    array( 'db' => '`rem`.`archived`',                         'dt' => 'archived',      'field' => 'archived'),
 );

// SQL server connection information
$sql_details = array(
    'user' => 'root',
    'pass' => 'root',
    'db'   => 'db_lang',
    '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( 'ssp.class.custo.php' );

/**
 * 1) Create Alias
 * 2) Target the concerned table
 * 3) Join with searched values
 * 4) Use it with initial table
**/
$joinQuery = "FROM `{$table}` AS `rem`
            JOIN `tab_status`    AS `stat`   ON (`rem`.`status`    = `stat`.`id_status`)
            JOIN `tab_technics`  AS `tech`   ON (`rem`.`technic`   = `tech`.`id_tech`)
            JOIN `tab_doc`       AS `doc`    ON (`rem`.`doc`       = `doc`.`id_doc`)
            JOIN `tab_user`      AS `user`    ON (`rem`.`doc`       = `user`.`id_user`)            
            ";

$extraWhere = "`rem`.`archived` = $archived";

// echo json_encode($extraWhere);

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

?>


Viewing all articles
Browse latest Browse all 82273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>