]> git.nbdom.net Git - nb.git/commitdiff
bin/dbq-dir2sqlite ul
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 2 Sep 2016 11:09:29 +0000 (13:09 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 2 Sep 2016 11:09:29 +0000 (13:09 +0200)
bin/dbq-dir2sqlite
etc/profile.d/functions
lib/php/db.php
lib/php/db/table.php

index 37f6d95c8669c4cb2fb67c96c08ee52d22e9b549..1dd30e27d17b400f6402739b8583c19c57687890 100755 (executable)
@@ -121,8 +121,10 @@ for vars in $(dbq a=ls type='!sqlite' out=sh); do
        [ -w "${id}.db" ] || continue
        [ "$VERBOSE" -gt 0 ] && printf '%s : ' "$id"
 
-       dbq f=text a=db.dump db.type=sqlite db="$id" > "$TMP_DB" 2>/dev/null
+  rm -f "$TMP_DB"
+       dbq f=text a=db.dump db.type=sqlite db="$id" 2>/dev/null | sqlite3 "$TMP_DB"
   ret=$?
+  #file "$TMP_DB"; du -sh "$TMP_DB"
        if [ "$ret" != "0" -o ! -s "$TMP_DB" ];then
          [ "$VERBOSE" -gt 0 ] && echo "failed"
     continue
index 729c9ed5b29db7026b9cc88e594ab959b549cf34..a09f45bb8c7994b1a16d956682c2c1d2f79042b7 100644 (file)
@@ -106,7 +106,15 @@ realpath() {
 }
 
 ascii() {
-  perl -e 'binmode(STDOUT, ":utf8"); for(32..255){ print "$_:".chr($_)."\n"; }'
+
+  if [ ! -t 0 ]; then
+    cat | perl -ne 'for (split("",$_)) { print sprintf("%3d",ord($_)).":$_\n"; }'
+  elif [ -n "$*" ]; then
+    perl -ne 'for (split("",$_)) { print sprintf("%3d",ord($_)).":$_\n"; }' $@
+  else
+    perl -e 'binmode(STDOUT, ":utf8"); for(32..255){ print "$_:".chr($_)."\n"; }'
+  fi
+
 }
 
 psmem() {
index 93f494a335410c29e37ec916330daf376c4d8d74..182810e019ace258f9c5e94a88949fbf115fe6c4 100644 (file)
@@ -692,7 +692,7 @@ class Db extends nb {
     # Contruct DROP / CREATE
     foreach ($tables as $t) {
 
-      $sql = rtrim($t->create(true),';');
+      $sql = rtrim($t->create(false),';');
       $sql = str_replace(';CREATE',";\nCREATE",$sql);
 
       if ($drop = $this->type('sql.drop')) {
index ed5c122e10b3d122c24bc168f72d5777cf7c4d5a..03038b0b3b40bc1969675d9edfd2443dc9b86174 100644 (file)
@@ -134,7 +134,7 @@ Class Table extends nb {
    * return the sql to create the table build internaly
    *
    */
-  public function create($from_sql=false) {
+  public function create($from_sql=true) {
 
     // String replace function
     $sql_replace_fct = $this->db()->type('sql.replace',false);
@@ -785,6 +785,11 @@ Class Table extends nb {
       $count++;
       $call = null;
 
+      # Delete char 0 (from wordpress)
+      foreach ($row as $k=>$v) {
+        $row[$k] = str_replace(chr(0),'',$v);
+      }
+
       if ($extras and !empty($this->db()->row_parse)) {
         $call = $this->db()->row_parse; $call($row);
       }
@@ -798,15 +803,6 @@ Class Table extends nb {
           if (!isset($this->extras[$k])) $row[$k] = out::format($v);
         }
 
-      /*
-      */
-      } elseif(0) {
-        //iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
-        foreach ($row as $k=>$v) {
-          #if (!isset($this->extras[$k])) $row[$k] = mb_convert_encoding($v, "UTF-8");
-          #if (!isset($this->extras[$k])) $row[$k] = preg_replace('/[\r\f]/','',$v);
-        }
-
       }
 
       if ($extras and !empty($this->row_parse_post)) {