Commit 060739d7 authored by zYne's avatar zYne

added Regexp operator compatibility for mysql and pgsql drivers

parent eacb7814
...@@ -126,6 +126,15 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -126,6 +126,15 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
public function getDBH() { public function getDBH() {
return $this->dbh; return $this->dbh;
} }
/**
* returns the regular expression operator
* (implemented by the connection drivers)
*
* @return string
*/
public function getRegexpOperator() {
throw new Doctrine_Connection_Exception('Regular expression operator is not supported by this database driver.');
}
/** /**
* query * query
* queries the database with Doctrine Query Language * queries the database with Doctrine Query Language
......
...@@ -14,10 +14,20 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common { ...@@ -14,10 +14,20 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$this->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS); $this->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS);
parent::__construct($manager,$pdo); parent::__construct($manager,$pdo);
} }
/**
* returns the regular expression operator
* (implemented by the connection drivers)
*
* @return string
*/
public function getRegexpOperator() {
return 'RLIKE';
}
/** /**
* deletes all data access object from the collection * deletes all data access object from the collection
* @param Doctrine_Collection $coll * @param Doctrine_Collection $coll
*/ */
/** /**
public function deleteCollection(Doctrine_Collection $coll) { public function deleteCollection(Doctrine_Collection $coll) {
......
...@@ -14,5 +14,14 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common { ...@@ -14,5 +14,14 @@ class Doctrine_Connection_Pgsql extends Doctrine_Connection_Common {
$data = $stmt->fetch(PDO::FETCH_NUM); $data = $stmt->fetch(PDO::FETCH_NUM);
return $data[0]; return $data[0];
} }
/**
* returns the regular expression operator
* (implemented by the connection drivers)
*
* @return string
*/
public function getRegexpOperator() {
return 'SIMILAR TO';
}
} }
...@@ -48,10 +48,11 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition { ...@@ -48,10 +48,11 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition {
$stack = $this->query->getTableStack(); $stack = $this->query->getTableStack();
switch($func) { switch($func) {
case 'contains': case 'contains':
$operator = ' = ';
case 'similarTo': case 'regexp':
case 'isLike': $operator = ' RLIKE ';
case 'like':
if(empty($relation)) if(empty($relation))
throw new Doctrine_Query_Exception('DQL function contains can only be used for fields of related components'); throw new Doctrine_Query_Exception('DQL function contains can only be used for fields of related components');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment