From 664a4ba787de31e93f4238988dc7d46c3e2f4395 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 8 Jan 2018 00:40:34 +0000 Subject: [PATCH] lib/php/db/types/sqlite.php --- lib/php/db.php | 2 +- lib/php/db/types/sqlite.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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); }, );?> -- 2.47.3