From 6a8052aad4fff187cb2add893d4e27e7fcb576e4 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 15 Dec 2022 12:10:19 +0100 Subject: [PATCH] Replace ar_map with array_map --- lib/php/db/table.php | 9 ++++++--- lib/php/nb.php | 1 + lib/php/page.php | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 1eb35f61..e0673e49 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -123,11 +123,13 @@ Class Table extends nb { $sql_names = $this->sql_names($fields); $this->db()->conn->query("CREATE ".$this->sql_temporary()." TABLE $this->name (" - .join(',',$this->ar_map('"$a text"',$sql_names)) + # NB 15.12.22 .join(',',$this->ar_map('"$a text"',$sql_names)) + .join(',',array_map(function($a){return("$a=text");},$sql_names)) .')'); $sql = 'INSERT INTO '. $this->sql_name("$this->name") . ' (' . join(',',array_values($sql_names)).')' - .' VALUES (' . join(',',$this->ar_map('":$a"',$fields)) . ')' + # NB 15.12.22 .' VALUES (' . join(',',$this->ar_map('":$a"',$fields)) . ')' + .' VALUES (' . join(',',array_map(function($a){return(":$a");},$fields)).')' ; #debug($sql); @@ -1778,7 +1780,8 @@ Class Table extends nb { $sql = $insert_word.' INTO '. $this->sql_name() . ' (' . join(',',array_values($sql_names)).')' - .' VALUES (' . join(',',$this->ar_map('":$a"',array_keys($fields))) . ')' + # NB 15.12.22 .' VALUES (' . join(',',$this->ar_map('":$a"',array_keys($fields))) . ')' + .' VALUES ('.join(',',array_map(function($a){return(":$a");},array_keys($fields))).')' ; if (!empty($info['fct'])) { diff --git a/lib/php/nb.php b/lib/php/nb.php index 5dc0b54b..853f796d 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -194,6 +194,7 @@ class Nb { * Does what it says */ public static function ar_map($return,$array,$as_hash=false) { + # NB 15.12.22: Depreciated use direct php arra_map functions $map = $array; # NB 30.11.22: Does not work get error message mb_strlen does not exists #bye($return); diff --git a/lib/php/page.php b/lib/php/page.php index 68e75e3e..3b55d215 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -256,7 +256,8 @@ class Page extends nb { foreach ($tags as $t) echo "".NB_EOL; $tags = []; return $tags; - return join('',self::ar_map('',$tags)); + return join(',',array_map(function($a){return('');},$tags)); + # NB 15.12.22 return join('',self::ar_map('',$tags)); if ($tag === null) return $tags; array_unshift($tags,$tag); } -- 2.47.3