YADCF + Datatables Server Side Populate Select with Php

本秂侑毒 提交于 2019-12-01 08:47:48

Well for anyone interested in the same topic

Thanks for the help of vedmack (YADCF) author i found the perfect solution:

modify the part from :

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

to:

$data=SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere );

$db = SSP::sql_connect( $sql_details );
$stmt3 = $db->prepare( 'SELECT DISTINCT(value) FROM esito' );
$stmt3->execute();
$data['yadcf_data_3'] = $stmt3->fetchAll(PDO::FETCH_COLUMN, 0);

$stmt5 = $db->prepare( 'SELECT DISTINCT(value2) FROM table' );
$stmt5->execute();
$data['yadcf_data_5'] = $stmt5->fetchAll(PDO::FETCH_COLUMN, 0);

$stmt6 = $db->prepare( 'SELECT DISTINCT(value3) FROM table' );
$stmt6->execute();
$data['yadcf_data_6'] = $stmt6->fetchAll(PDO::FETCH_COLUMN, 0);


echo json_encode($data);

So we make a custom query for each select field we have (In my case i had 3) And re-include the $db since i have my ssp.class.php in different file

Hope it helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!