mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
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:
parent
353a842d68
commit
2ceea18a77
5 changed files with 52 additions and 7 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* @brief Cubrid DBMS to use the class
|
||||
* @version 1.0
|
||||
*
|
||||
* Works with CUBRID up to 8.4.0
|
||||
* Works with CUBRID up to 8.4.1
|
||||
**/
|
||||
|
||||
class DBCubrid extends DB
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
**/
|
||||
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"]);
|
||||
|
||||
// check connections
|
||||
|
|
@ -75,7 +75,15 @@
|
|||
$this->setError (-1, 'database connect fail');
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -108,7 +108,11 @@
|
|||
case 'like_tail' :
|
||||
case 'like_prefix' :
|
||||
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;
|
||||
case 'notlike_tail' :
|
||||
case 'notlike_prefix' :
|
||||
|
|
|
|||
|
|
@ -23,13 +23,27 @@
|
|||
|
||||
switch($operation) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
case 'notlike' :
|
||||
$this->value = '%'.$value.'%';
|
||||
|
|
|
|||
|
|
@ -392,5 +392,13 @@
|
|||
where "expired" <= \'' . date("YmdHis") . '\'';
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
11
tests/classes/db/db/xml_query/cubrid/data/rlike1.xml
Normal file
11
tests/classes/db/db/xml_query/cubrid/data/rlike1.xml
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue