From 8becc359ea512cb28f3f6ec263228fb20a9588f3 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 28 Sep 2016 18:20:50 +0200 Subject: [PATCH] try to escape chars when dbq2... --- lib/php/db.php | 4 ++++ lib/php/db/table.php | 6 ++++-- lib/php/db/types/sqlite.php | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index 0304ffa0..00fde73f 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -822,6 +822,9 @@ class Db extends nb { echo rtrim($s,';').";\n"; } + #bye($this->db()->type); + $fct = $this->conf_type('table.sql.create',false); + if (!$fct) $fct = false; foreach ($tables as $t) { # DROP / CREATE @@ -855,6 +858,7 @@ class Db extends nb { $t->rows(); if ($type_to) $this->type = $type_to; } + } $i = 0; foreach ((array)$this->method('sql.post') as $s) { diff --git a/lib/php/db/table.php b/lib/php/db/table.php index a4ab8112..9f85f3b2 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -985,8 +985,10 @@ Class Table extends nb { $keys[] = $f->sql_name(); } - return "INSERT INTO ".$this->sql_name()." VALUES (".join(',',array_values($values)).");".NB_EOL; - return "INSERT INTO ".$this->sql_name()." (".join(',',$keys).") VALUES (".join(',',array_values($values)).");".NB_EOL; + $sql = "INSERT INTO ".$this->sql_name()." VALUES (".join(',',array_values($values)).");"; + #$sql = "INSERT INTO ".$this->sql_name()." (".join(',',$keys).") VALUES (".join(',',array_values($values)).");"; + #if ($fct and $this->name=='place') debug($sql); + return $sql.NB_EOL; } public function rows_end_sql() { diff --git a/lib/php/db/types/sqlite.php b/lib/php/db/types/sqlite.php index ab3f220f..0e6ed43a 100644 --- a/lib/php/db/types/sqlite.php +++ b/lib/php/db/types/sqlite.php @@ -107,6 +107,10 @@ $DB_TYPES['sqlite'] = array ( 'table.sql.create' => function($sql,$t) { #$sql .= $t->db()->row("SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name=".$t->sql_name()); $sql = str_replace("\\'","''",$sql); + #$sql = preg_replace("/\\'/","''",$sql); + #$sql = 'espace'; + #$sql = "zaza $sql"; + #debug($sql); return $sql; }, );?> -- 2.47.3