Skip to content

Commit

Permalink
Fixed syntax for regex searches for newer MySQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Hannah committed May 22, 2023
1 parent 1b72598 commit 8c9eb40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dataface/QueryBuilder.php
Expand Up @@ -708,7 +708,7 @@ function _fieldWhereClause(&$field, $value, &$use_where, $tableAlias=null){
$oldval = trim($value);
$value = $this->prepareValue( $key, $table->parse($key, $value), true );
if ( $repeat ){
$where .= $this->wc($tableAlias, $key, $collate)." NOT RLIKE CONCAT('[[:<:]]',$value,'[[:>:]]') AND ";
$where .= $this->wc($tableAlias, $key, $collate)." NOT REGEXP CONCAT('\\b',$value,'\\b') AND ";
} else {
$oper = '<>';
if ( strlen($oldval) === 0 ){
Expand Down Expand Up @@ -775,7 +775,7 @@ function _fieldWhereClause(&$field, $value, &$use_where, $tableAlias=null){

} else if ( $repeat ){
$value = $this->prepareValue( $key, $table->parse($key, $value), true);
$where .= $this->wc($tableAlias, $key, $collate)." RLIKE CONCAT('[[:<:]]',$value,'[[:>:]]') AND ";
$where .= $this->wc($tableAlias, $key, $collate)." REGEXP CONCAT('\\b',$value,'\\b') AND ";
}

else if ( $this->_exactMatches || preg_match( '/int|decimal/i', $field['Type']) || $exact ){
Expand Down
5 changes: 1 addition & 4 deletions xf/db/drivers/mysqli.php
Expand Up @@ -12,10 +12,7 @@ function xf_db_connect($host,$user,$pass){
function xf_db_connect_errno(){ return mysqli_connect_errno();}
function xf_db_connect_error(){ return mysqli_connect_error();}
function xf_db_query($sql, $conn=null){
if ($conn === null) {
$conn = df_db();
}
return mysqli_query($conn, $sql);
return mysqli_query($conn ?? df_db(), $sql);
}
function xf_db_error($link=null){
if ( $link === null ){
Expand Down

0 comments on commit 8c9eb40

Please sign in to comment.