Hej. Mam problem z PDO z MySQL. Mianowicie mam tu taki kod
public function insertUpdateQuery($query, array $parameters = array())
{
try
{
$this->sqlPDO->beginTransaction();
$stm = $this->sqlPDO->prepare($query);
if(count($parameters) > 0)
{
$this->prepareParameters($stm, $parameters);
}
$stm->execute();
$this->sqlPDO->commit();
}
catch(PDOException $ex)
{
$this->sqlPDO->rollBack();
throw $ex;
}
}
private function prepareParameters(PDOStatement $stm, $parameters)
{
foreach($parameters as $key => $value)
{
$v = trim(htmlspecialchars(addslashes($value)));
$stm->bindParam($key, $v);
}
}
Problem tkwi w tym, że binduje mi tylko pierwszy parametr a pozostałe są takie jak pierwsze. Tu zapytanie
$sql->insertUpdateQuery("INSERT INTO order_album (name, surname, city, street, postcode, additional) VALUES ( :name, :surname, :city, :street, :postcode, :additional )", array(
'name' => $name,
'surname' => $surname,
'city' => $city,
'street' => $street,
'postcode' => $postcode,
'additional' => $additional,
));
Prosiłbym o pomoc w rozwiązaniu tego problemu