Mysql
 sql >> Base de données >  >> RDS >> Mysql

DataTables utilisant PHP avec MySQL :Comment modifier la requête mysql ?

/*
* Filtering
 * NOTE this does not match the built-in DataTables filtering which does it
 * word by word on any field. It's possible to do here, but concerned about efficiency
 * on very large tables, and MySQL's regex functionality is very limited
 */

//$sWhere = "";

if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" )
{
$sWhere = "WHERE id='4' AND (";
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
    if ( isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == "true" )
    {
        $sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
    }
}
$sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ')';
} else {
$sWhere = "WHERE id = '4' ";
}