From 223df191750264bb47d00349b6a4e2b0aad5d777 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Thu, 24 Oct 2019 19:38:06 +0100 Subject: [PATCH] Fix ar_map eval needed since php 7 --- lib/php/db/table.php | 3 +-- lib/php/nb.php | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 4d4f074d..b4d4b7bc 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1886,9 +1886,8 @@ Class Table extends nb { .' SET ' . join(',',$this->ar_map('"$a=:$a"',$fields)) .' WHERE ' . join(' AND ',$this->ar_map('"$a=:key_$a"',$keys)) ; - #$info['sql'] = $sql; - #bye($sql); $info = [ 'sql' => $sql ] + $info; + $this->file_write('/tmp/nb',print_r($info,true)); if ($bindParam and !($query = $this->db()->conn->prepare($sql))) { $this->err('PDO::errorInfo(): ' .join(' ', $this->db()->conn->errorInfo()) .NB_EOL); diff --git a/lib/php/nb.php b/lib/php/nb.php index dc81c3ea..ce2c6515 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -193,8 +193,11 @@ class Nb { * Does what it says */ public static function ar_map($return,$array,$as_hash=false) { - #return ar_map($return,$array,$as_hash); - $map = array_map(function($a) use($return) { return($return); },$array); + $map = array_map(function($a) use($return) { + if (PHP_VERSION_ID>=70000) eval('$return='.$return.';'); + return($return); + },$array); + #$map = array_map(function($a) use($return) { $return = str_replace('$a',$a,$return); return($return); },$array); if ($as_hash) { -- 2.47.3