wpdatatables_filter_mysql_query

Contents

Description

This filter is applied to the MySQL query before it is sent to MySQL server.

Usage

add_filter( 'wpdatatables_filter_mysql_query', 'filter_mysql_query', 10, 2 );

Parameters

  • $query query
    Query text.
  • $tableId integer
    ID of table from database.

Examples

// Callback function for the wpdatatables_filter_mysql_query filter hook
function filter_mysql_query( $query, $tableId ) { 
  $month = 3;
  if ( $table_id == 18 ) {
    
      $query = "SELECT tTransactions.`id_transaction`,
                tTransactions.`transaction_date`,
                tTransactions.`id_product`
                FROM tTransactions
                where month(tTransactions.`transaction_date`)=". $month;
   }
   return $query;
}

add_action( 'wpdatatables_filter_mysql_query', 'filter_mysql_query', 10, 2);