commit dd1d48bb4c26c0aa547d76a875979ceb9146cd3f
parent 5a9f53c823866ac22a8b37a08e37476c12d3c9af
Author: Friedel Schon <[email protected]>
Date: Tue, 11 Apr 2023 13:28:30 +0200
mysqli::bind_param -> ::execute
Diffstat:
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/Lollipop/DatabaseObject.php b/Lollipop/DatabaseObject.php
@@ -27,8 +27,7 @@ namespace Lollipop {
$sql = "SELECT * FROM {$this->table} WHERE {$this->primary} = ?";
$stmt = $this->db->conn->prepare($sql);
- $stmt->bind_param("s", $id);
- $stmt->execute();
+ $stmt->execute([$id]);
$result = $stmt->get_result();
if ($result->num_rows == 0) {
@@ -47,22 +46,18 @@ namespace Lollipop {
$sql = "UPDATE {$this->table} SET ";
$values = [];
- $types = "";
foreach ($this->changed_keys as $index => $key) {
if ($index > 0)
$sql .= ', ';
$sql .= "$key = ?";
$values[] = $this->data[$key];
- $types .= 's';
}
$sql .= " WHERE $this->primary = ?";
$values[] = $this->data[$this->primary];
- $types .= 's';
$stmt = $this->db->conn->prepare($sql);
- $stmt->bind_param($types, ...$values);
- $stmt->execute();
+ $stmt->execute($values);
$this->changed_keys = [];
}
@@ -71,8 +66,7 @@ namespace Lollipop {
{
$sql = "DELETE FROM {$this->table} WHERE {$this->primary} = ?";
$stmt = $this->db->conn->prepare($sql);
- $stmt->bind_param("s", $this->data[$this->primary]);
- $stmt->execute();
+ $stmt->execute([$this->data[$this->primary]]);
$this->data = [];
$this->changed_keys = [];
}