Skip to content

Commit

Permalink
Fix - PHP: Support for server-side processing search on non-text fiel…
Browse files Browse the repository at this point in the history
…ds with Postgres

- DD-918
  • Loading branch information
AllanJard committed May 22, 2019
1 parent fcfd644 commit 258ecde
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function __construct( $opts )
);
}

$this->type = $opts['type'];
$this->query_driver = "DataTables\\Database\\Driver\\".$opts['type'].'Query';
$this->_dbResource = isset( $opts['pdo'] ) ?
$opts['pdo'] :
Expand Down
23 changes: 17 additions & 6 deletions Database/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,12 +1132,23 @@ protected function _where ( $where, $value=null, $type='AND ', $op="=", $bind=tr
}
else if ( $bind ) {
// Binding condition (i.e. escape data)
$this->_where[] = array(
'operator' => $type,
'group' => null,
'field' => $this->_protect_identifiers($key),
'query' => $this->_protect_identifiers($key) .' '.$op.' '.$this->_safe_bind(':where_'.$i)
);
if ( $this->_dbHost->type === 'Postgres' && $op === 'like' ) {
// Postgres specific a it needs a case for string searching non-text data
$this->_where[] = array(
'operator' => $type,
'group' => null,
'field' => $this->_protect_identifiers($key),
'query' => $this->_protect_identifiers($key).'::text ilike '.$this->_safe_bind(':where_'.$i)
);
}
else {
$this->_where[] = array(
'operator' => $type,
'group' => null,
'field' => $this->_protect_identifiers($key),
'query' => $this->_protect_identifiers($key) .' '.$op.' '.$this->_safe_bind(':where_'.$i)
);
}
$this->bind( ':where_'.$i, $value );
}
else {
Expand Down

0 comments on commit 258ecde

Please sign in to comment.