From 3a3addf7b08618674e21a8e8576302c77c72c71f Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Wed, 7 Sep 2016 06:04:01 +0200 Subject: [PATCH] Added support for add arrays to where sql statements --- src/Webmodel.php | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Webmodel.php b/src/Webmodel.php index c98603c..3f10471 100644 --- a/src/Webmodel.php +++ b/src/Webmodel.php @@ -775,9 +775,44 @@ class Webmodel { $quot=''; + } + else + if(gettype($arg)==='array') + { + + array_walk($arg, function(&$item, $key) { + + $quot_array='"'; + + if(gettype($item)==='integer' || gettype($item)==='float') + { + + $quot_array=''; + + } + else + { + $item=$this->escape_string($item); + + } + + $item=$quot_array.$item.$quot_array; + + }); + + $arg='('.implode(', ', $arg).')'; + + $quot=''; + + } + else + { + + $arg=$this->escape_string($arg); + } - $arr_conditions[$key]=trim($arr_conditions[$key].$quot.$this->escape_string($arg).$quot); + $arr_conditions[$key]=trim($arr_conditions[$key].$quot.$arg.$quot); }