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
@ -67,7 +67,7 @@
**/ **/
function __connect($connection) function __connect($connection)
{ {
// attempts to connect // attempts to connect
$result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]); $result = @cubrid_connect($connection["db_hostname"], $connection["db_port"], $connection["db_database"], $connection["db_userid"], $connection["db_password"]);
// check connections // check connections
@ -75,7 +75,15 @@
$this->setError (-1, 'database connect fail'); $this->setError (-1, 'database connect fail');
return; return;
} }
return $result;
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;
} }
/** /**

View file

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

View file

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

View file

@ -392,5 +392,13 @@
where "expired" <= \'' . date("YmdHis") . '\''; where "expired" <= \'' . date("YmdHis") . '\'';
$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>