Added support for CUBRID 8.4.1. "RLIKE" statement.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10070 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2012-02-02 18:22:07 +00:00
parent 353a842d68
commit 2ceea18a77
5 changed files with 52 additions and 7 deletions

View file

@ -5,7 +5,7 @@
* @brief Cubrid DBMS to use the class * @brief Cubrid DBMS to use the class
* @version 1.0 * @version 1.0
* *
* Works with CUBRID up to 8.4.0 * Works with CUBRID up to 8.4.1
**/ **/
class DBCubrid extends DB class DBCubrid extends DB
@ -75,6 +75,14 @@
$this->setError (-1, 'database connect fail'); $this->setError (-1, 'database connect fail');
return; return;
} }
if(!defined('__CUBRID_VERSION__')) {
$cubrid_version = cubrid_get_server_info($result);
$cubrid_version_elem = explode('.', $cubrid_version);
$cubrid_version = $cubrid_version_elem[0] . '.' . $cubrid_version_elem[1] . '.' . $cubrid_version_elem[2];
define('__CUBRID_VERSION__', $cubrid_version);
}
return $result; return $result;
} }

View file

@ -108,6 +108,10 @@
case 'like_tail' : case 'like_tail' :
case 'like_prefix' : case 'like_prefix' :
case 'like' : case 'like' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1')
return $name.' rlike '.$value;
else
return $name.' like '.$value; return $name.' like '.$value;
break; break;
case 'notlike_tail' : case 'notlike_tail' :

View file

@ -23,12 +23,26 @@
switch($operation) { switch($operation) {
case 'like_prefix' : case 'like_prefix' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1') {
$this->value = '^' . str_replace('%', '(.*)', preg_quote($value));
}
else
$this->value = $value.'%'; $this->value = $value.'%';
break; break;
case 'like_tail' : case 'like_tail' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1')
$this->value = str_replace('%', '(.*)', preg_quote($value)) . '$';
else
$this->value = '%'.$value; $this->value = '%'.$value;
break; break;
case 'like' : case 'like' :
if(defined('__CUBRID_VERSION__')
&& __CUBRID_VERSION__ >= '8.4.1') {
$this->value = str_replace('%', '(.*)', preg_quote($value));
}
else
$this->value = '%'.$value.'%'; $this->value = '%'.$value.'%';
break; break;
case 'notlike' : case 'notlike' :

View file

@ -393,4 +393,12 @@
$this->_test($xml_file, $argsString, $expected); $this->_test($xml_file, $argsString, $expected);
} }
function test_rlike_1(){
$xml_file = _TEST_PATH_ . "db/xml_query/cubrid/data/rlike1.xml";
$argsString = '$args->title = "aaa";';
$expected = 'select * from "xe_modules" as "modules" where "title" rlike \'aaa\'';
define('__CUBRID_VERSION__', '8.4.1');
$this->_test($xml_file, $argsString, $expected);
}
} }

View file

@ -0,0 +1,11 @@
<query id="testRlike1" action="select">
<tables>
<table name="modules" />
</tables>
<columns>
<column name="*" />
</columns>
<conditions>
<condition operation="like" column="title" var="title" />
</conditions>
</query>