dblayeroo: Accept only one setValues
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3481 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -1525,10 +1525,8 @@ class dblayeroo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Set INSERT/UPDATE values
|
/** 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
|
* 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
|
* @param array $values The values to INSERT or UPDATE
|
||||||
*/
|
*/
|
||||||
public function setValues ($values)
|
public function setValues ($values)
|
||||||
@@ -1539,38 +1537,15 @@ class dblayeroo
|
|||||||
$associative = null;
|
$associative = null;
|
||||||
$tmpValues = array ();
|
$tmpValues = array ();
|
||||||
$tmpType = array ();
|
$tmpType = array ();
|
||||||
$tmpField = array ();
|
|
||||||
foreach ($values as $key=>$val)
|
foreach ($values as $key=>$val)
|
||||||
{
|
{
|
||||||
if ($associative === null)
|
if (! array_key_exists ($key, $this->fields))
|
||||||
{
|
$this->DBException (sprintf (
|
||||||
if ($key === 0)
|
"Invalid field to setValues '%s' : not defined in table", $key));
|
||||||
$associative = false;
|
$tmpValues[$key] = $val;
|
||||||
elseif (is_string ($key) && strlen (trim ($key)) !== 0)
|
$tmpType[md5 ("$key, $val")] = $this->fieldTypeLight ($key);
|
||||||
$associative = true;
|
$this->debugLog ("setValues : Type for $key = ".
|
||||||
}
|
$this->fieldTypeLight ($key));
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->setValues = $tmpValues;
|
$this->setValues = $tmpValues;
|
||||||
$this->setType = $tmpType;
|
$this->setType = $tmpType;
|
||||||
|
|||||||
Reference in New Issue
Block a user