Commit 9e35702c authored by zYne's avatar zYne

Sqlite driver: added support for md5, mod and concat

parent 76f4bfb9
...@@ -72,6 +72,15 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common { ...@@ -72,6 +72,15 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common {
parent::__construct($manager, $pdo); parent::__construct($manager, $pdo);
} }
/**
* initializes database functions missing in sqlite
*/
public function initFunctions() {
$this->dbh->sqliteCreateFunction('md5', array('Doctrine_Expression_Sqlite', 'md5Impl'), 1);
$this->dbh->sqliteCreateFunction('mod', array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
$this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl'));
$this->dbh->sqliteCreateFunction('now', 'time', 0);
}
/** /**
* Set the transacton isolation level. * Set the transacton isolation level.
* *
......
...@@ -27,6 +27,32 @@ Doctrine::autoload('Doctrine_Expression'); ...@@ -27,6 +27,32 @@ Doctrine::autoload('Doctrine_Expression');
* @license LGPL * @license LGPL
*/ */
class Doctrine_Expression_Sqlite extends Doctrine_Expression { class Doctrine_Expression_Sqlite extends Doctrine_Expression {
/**
* Returns the md5 sum of the data that SQLite's md5() function receives.
*
* @return string
*/
public static function md5Impl($data) {
return md5($data);
}
/**
* Returns the modules of the data that SQLite's mod() function receives.
*
* @return string
*/
public static function modImpl($dividend, $divisor) {
return $dividend % $divisor;
}
/**
* Returns a concattenation of the data that SQLite's concat() function receives.
*
* @return string
*/
public static function concatImpl() {
$args = func_get_args();
return join( '', $args );
}
/** /**
* returns the regular expression operator * returns the regular expression operator
* *
......
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