Commit f8b96636 authored by zYne's avatar zYne

Ported index/sequence name fixing and common manager functionality from MDB2

parent 311131b5
......@@ -28,6 +28,7 @@
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (MDB2 library)
*/
abstract class Doctrine_Connection extends Doctrine_Configurable implements Countable, IteratorAggregate {
/**
......@@ -167,6 +168,34 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this->supported[$feature] === 'emulated' ||
$this->supported[$feature]);
}
/**
* Removes any formatting in an sequence name using the 'seqname_format' option
*
* @param string $sqn string that containts name of a potential sequence
* @return string name of the sequence with possible formatting removed
*/
public function fixSequenceName($sqn) {
$seq_pattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $db->options['seqname_format']).'$/i';
$seq_name = preg_replace($seq_pattern, '\\1', $sqn);
if ($seq_name && ! strcasecmp($sqn, $db->getSequenceName($seq_name))) {
return $seq_name;
}
return $sqn;
}
/**
* Removes any formatting in an index name using the 'idxname_format' option
*
* @param string $idx string that containts name of anl index
* @return string name of the index with possible formatting removed
*/
public function fixIndexName($idx) {
$idx_pattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $db->options['idxname_format']).'$/i';
$idx_name = preg_replace($idx_pattern, '\\1', $idx);
if ($idx_name && !strcasecmp($idx, $db->getIndexName($idx_name))) {
return $idx_name;
}
return $idx;
}
/**
* returns a datadict object
*
......
This diff is collapsed.
......@@ -34,6 +34,7 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
/**
* Returns the md5 sum of the data that SQLite's md5() function receives.
*
* @param mixed $data
* @return string
*/
public static function md5Impl($data) {
......@@ -42,6 +43,8 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
/**
* Returns the modules of the data that SQLite's mod() function receives.
*
* @param integer $dividend
* @param integer $divisor
* @return string
*/
public static function modImpl($dividend, $divisor) {
......@@ -49,7 +52,7 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
}
/**
* Returns a concattenation of the data that SQLite's concat() function receives.
* Returns a concatenation of the data that SQLite's concat() function receives.
*
* @return string
*/
......@@ -57,6 +60,30 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
$args = func_get_args();
return join( '', $args );
}
/**
* locate
* returns the position of the first occurrence of substring $substr in string $str that
* SQLite's locate() function receives
*
* @param string $substr literal string to find
* @param string $str literal string
* @return string
*/
public static function locateImpl($substr, $str) {
return strpos($str, $substr);
}
public static function sha1($str) {
return sha1($str);
}
public static function ltrim($str) {
return ltrim($str);
}
public static function rtrim($str) {
return rtrim($str);
}
public static function trim($str) {
return trim($str);
}
/**
* returns the regular expression operator
*
......@@ -65,6 +92,19 @@ class Doctrine_Expression_Sqlite extends Doctrine_Expression {
public function regexp() {
return 'RLIKE';
}
/**
* soundex
* Returns a string to call a function to compute the
* soundex encoding of a string
*
* The string "?000" is returned if the argument is NULL.
*
* @param string $value
* @return string SQL soundex function with given parameter
*/
public function soundex($value) {
return 'SOUNDEX(' . $value . ')';
}
/**
* Return string to call a variable with the current timestamp inside an SQL statement
* There are three special variables for current date and time.
......
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