I am trying to get associative%% as argument of this methods, actually receive a array
in the first argument and a numeric value in the second.
My question is how to make the array
variable not repeat?
Well, you're giving this error:
Warning: PDOStatement :: execute () [pdostatement.execute]: SQLSTATE [HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C: \ Program Files (x86) \ EasyPHP-5.3.8.0 \ www \ connect \ standardModel.php on line 92
Source:
<?php
public function update($data = array(), $id)
{
if (is_array($data) && count($data) > 0 && $id != false)
{
$sql = "update '{$this->table}' set ";
foreach($data as $key => $value)
{
$sql .= $key . " = ?, ";
}
$sql = substr($sql, 0, - 2);
$sql .= "where id = ?";
$query = $this->db->prepare($sql);
foreach($data as $value)
{
$query->bindValue($value . ",",$id);
}
if ($query->execute()) {
return true;
} else {
return false;
}
}
}
?>