Compare commits

...

2 Commits

View File

@ -44,7 +44,7 @@ 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, ",");
@ -70,7 +70,7 @@ class BancaDati {
public function update(string $table, string $id, array $values){ public function update(string $table, string $id, array $values){
$value = ""; $value = "";
foreach ($values as $col => $v){ foreach ($values as $col => $v){
$value .= $col . "=" . $v . ","; $value .= $col . "='" . $v . "',";
} }
$value = trim($value, ","); $value = trim($value, ",");
@ -91,7 +91,7 @@ class BancaDati {
* @author Malte Schulze Hobeling * @author Malte Schulze Hobeling
*/ */
public function delete(string $table, string $id){ public function delete(string $table, string $id){
$sql = "DELETE FROM " . $table . " WHERE `id` = " . $id . ";"; $sql = "DELETE FROM " . $table . " WHERE `id` = '" . $id . "';";
try { try {
$sth = $this->pdo->prepare($sql); $sth = $this->pdo->prepare($sql);
$sth->execute(); $sth->execute();
@ -114,9 +114,9 @@ class BancaDati {
if($whereString != ""){ if($whereString != ""){
$whereString .= " AND "; $whereString .= " AND ";
} }
$whereString .= $col . " LIKE " . $v; $whereString .= "`" . $col . "` = '" . $v . "'";
} }
$sql = "SELECT * FROM ".$table." WHERE ".$whereString; $sql = "SELECT * FROM ".$table." WHERE ".$whereString.";";
if(isset($order["by"])){ if(isset($order["by"])){
$sql .= " ORDER BY ".$order["by"]; $sql .= " ORDER BY ".$order["by"];
} }
@ -124,6 +124,7 @@ class BancaDati {
$sql .= $order["order"]; $sql .= $order["order"];
} }
try { try {
var_dump($sql);
return $this->pdo->query($sql); return $this->pdo->query($sql);
}catch (PDOException $e){ }catch (PDOException $e){
die; die;