diff --git a/dblayeroo.php b/dblayeroo.php index cbe969b..550e5e4 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -1525,10 +1525,8 @@ class dblayeroo } /** Set INSERT/UPDATE values - * - If the provided array is a associative array, the field name must be + * - The provided array must be an associative array, the field name must be * provided as key and the value as value. Each field=>val will be updated - * - It the provided array is a numeric array, it must be 2 long. The first - * is the field name, and the second the value * @param array $values The values to INSERT or UPDATE */ public function setValues ($values) @@ -1539,38 +1537,15 @@ class dblayeroo $associative = null; $tmpValues = array (); $tmpType = array (); - $tmpField = array (); foreach ($values as $key=>$val) { - if ($associative === null) - { - if ($key === 0) - $associative = false; - elseif (is_string ($key) && strlen (trim ($key)) !== 0) - $associative = true; - } - elseif ($associative === false && - is_string ($key) && strlen (trim ($key)) !== 0) - $this->DBException ("Invalid values to setValues : mixed array"); - elseif ($associative === true && is_int ($key)) - $this->DBException ("Invalid values to setValues : mixed array"); - - if ($associative === true) - { - if (! array_key_exists ($key, $this->fields)) - $this->DBException (sprintf ( - "Invalid field to setValues '%s' : not defined in table", $key)); - $tmpValues[$key] = $val; - $tmpField[md5 ("$key, $val")] = $key; - $tmpType[md5 ("$key, $val")] = $this->fieldTypeLight ($key); - $this->debugLog ("setValues : Type for $key = ". - $this->fieldTypeLight ($key)); - } - else - { - $values = array_values ($values); - $tmpValues[$values[0]] = $values[1]; - } + if (! array_key_exists ($key, $this->fields)) + $this->DBException (sprintf ( + "Invalid field to setValues '%s' : not defined in table", $key)); + $tmpValues[$key] = $val; + $tmpType[md5 ("$key, $val")] = $this->fieldTypeLight ($key); + $this->debugLog ("setValues : Type for $key = ". + $this->fieldTypeLight ($key)); } $this->setValues = $tmpValues; $this->setType = $tmpType;