From: Nicolas Boisselier Date: Mon, 8 Jan 2018 00:40:34 +0000 (+0000) Subject: lib/php/db/types/sqlite.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=664a4ba787de31e93f4238988dc7d46c3e2f4395;p=nb.git lib/php/db/types/sqlite.php --- diff --git a/lib/php/db.php b/lib/php/db.php index 7d7003bb..20b6226c 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -1010,8 +1010,8 @@ class Db extends nb { # Change db type if needed $type_from = $type_to = ''; if ($db_type) { - echo "-- Type orig: ".$this->type."\n"; echo "-- Type : ".$db_type."\n"; + echo "-- Type from: ".$this->type."\n"; $type_from = $this->type; $type_to = $db_type; $this->type = $type_to; diff --git a/lib/php/db/types/sqlite.php b/lib/php/db/types/sqlite.php index f98d3c74..5780a44e 100644 --- a/lib/php/db/types/sqlite.php +++ b/lib/php/db/types/sqlite.php @@ -160,8 +160,10 @@ $DB_TYPES['sqlite'] = array ( '/"([\w_]+)"\(/' => '$1(', # pgsql function quoted; "/'([\w_]+\(.*?\))'/" => '$1', # pgsql function quoted; "/now\(\)/i" => 'CURRENT_TIMESTAMP', # pgsql function quoted; + '/left\((.*?),\s*(\d+)\s*\)/i' => 'SUBSTR($1,0,$2)', # function left to substr + '/right\((.*?),\s*(\d+)\s*\)/i' => 'SUBSTR($1,$2,LENGTH($1))', # function right to substr ]; - $sql= preg_replace(array_keys($r),array_values($r),$sql); - return $sql; + + return preg_replace(array_keys($r),array_values($r),$sql); }, );?>