sql >> Database >  >> RDS >> Mysql

DataTables met PHP met MySQL:Hoe de mysql-query wijzigen?

/*
* 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' ";
}


  1. Selecteer waar het aantal van één veld groter is dan één

  2. mysql query kamer beschikbaarheid

  3. CURRENT_TIMESTAMP in milliseconden

  4. SQLite JSON_GROUP_ARRAY()