fix: insert vales with single quotes

This commit is contained in:
Johannes Kantz 2023-01-12 14:28:40 +01:00
parent 95a2c3e3fe
commit 23cf1b54e4

View File

@ -44,17 +44,19 @@ class BancaDati {
$value = ""; $value = "";
$column = ""; $column = "";
foreach ($values as $col => $v){ foreach ($values as $col => $v){
$value .= $v . ","; $value .= "'" . $v . "'" . ",";
$column .= $col . ","; $column .= $col . ",";
} }
$value = trim($value, ","); $value = trim($value, ",");
$column = trim($column, ","); $column = trim($column, ",");
$sql = "INSERT INTO $table ($column) VALUES ($value);"; $sql = "INSERT INTO $table ($column) VALUES ($value);";
var_dump($sql);
try { try {
$sth = $this->pdo->prepare($sql); $sth = $this->pdo->prepare($sql);
$sth->execute(); $sth->execute();
}catch (PDOException $e){ }catch (PDOException $e){
var_dump($e);
die; die;
} }
} }