Datatable does interpet MYSQL statement correctly in serve side pagination
Datatable does interpet MYSQL statement correctly in serve side pagination
Hi!
I am trying to use the server side pagination across 2 tables. the results return work well when I use a single condition MYSQL query for example
:
$sWhere = "WHERE APPLICATION.APPLICATIONID LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.FIRSTNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.LASTNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"USER.USERNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.STATUS LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' "
it works fine but when i use more than one condition [where x=y AND (a like b OR c like d ) ] shown below: the code behaves as if x=y does not exist and continues executing the OR conditions (a like b OR c like d ).
I have listed i am using below, can someone help me please.............
thanks in advance.
<?php
/* MySQL connection */
$gaSql['user'] = "***************";
$gaSql['password'] = "*********************";
$gaSql['db'] = "*************************";
$gaSql['server'] = "localhost";
$gaSql['type'] = "mysql";
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/* Paging */
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/* Ordering */
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
I am trying to use the server side pagination across 2 tables. the results return work well when I use a single condition MYSQL query for example
:
$sWhere = "WHERE APPLICATION.APPLICATIONID LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.FIRSTNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.LASTNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"USER.USERNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.STATUS LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' "
it works fine but when i use more than one condition [where x=y AND (a like b OR c like d ) ] shown below: the code behaves as if x=y does not exist and continues executing the OR conditions (a like b OR c like d ).
I have listed i am using below, can someone help me please.............
thanks in advance.
<?php
/* MySQL connection */
$gaSql['user'] = "***************";
$gaSql['password'] = "*********************";
$gaSql['db'] = "*************************";
$gaSql['server'] = "localhost";
$gaSql['type'] = "mysql";
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/* Paging */
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/* Ordering */
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
This discussion has been closed.
Replies
no response.
Anyways I solved it:
An 'else' statement was needed to fix the issue, (note to the developer).
$sWhere = "";
if ( $_GET['sSearch'] != "" )
{
$sWhere = "WHERE APPLICATION.USERID = USER.USERID AND ".
"( APPLICATION.APPLICATIONID LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.FIRSTNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.LASTNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"USER.USERNAME LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ".
"APPLICATION.STATUS LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' )".
" "; //here is my closing bracket
}
else {
$sWhere = "WHERE APPLICATION.USERID = USER.USERID ";
}