]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/types/sqlite.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Jan 2018 00:40:34 +0000 (00:40 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 8 Jan 2018 00:40:34 +0000 (00:40 +0000)
lib/php/db.php
lib/php/db/types/sqlite.php

index 7d7003bba3498bc3da45414f1cc0fb1e1a67c6bf..20b6226ca3ad954218c17cef09a32dcf13155c63 100644 (file)
@@ -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;
index f98d3c7481fad6ac1c89414ffaaed317e0c1d590..5780a44eb4bde31e32ba9129473dfc93e9b3a796 100644 (file)
@@ -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);
 },
 );?>