diff --git a/lib/Doctrine/Connection/Sqlite.php b/lib/Doctrine/Connection/Sqlite.php index dd5b8c8bc..643c0aec9 100644 --- a/lib/Doctrine/Connection/Sqlite.php +++ b/lib/Doctrine/Connection/Sqlite.php @@ -72,6 +72,15 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common { 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. * diff --git a/lib/Doctrine/Expression/Sqlite.php b/lib/Doctrine/Expression/Sqlite.php index db94d11a4..341cf7a7e 100644 --- a/lib/Doctrine/Expression/Sqlite.php +++ b/lib/Doctrine/Expression/Sqlite.php @@ -27,6 +27,32 @@ Doctrine::autoload('Doctrine_Expression'); * @license LGPL */ 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 *