I found this code. How is it possible to use a variable (the delete command), before defining it? My understanding, at least - is that this sets :id to the value of $id.
$this->db->query('DELETE FROM sessions WHERE id = :id');
$this->db->bind(':id', $id);
Here, :id
is not a variable, it's a named placeholder.
In the second statement, you just tell PDO to bind the value of $id
with the :id
placeholder.
See the documentation .
You have to use prepare
. Query makes only a query. So you have to prepare it first.
$stmt = $db->prepare("DELETE FROM sessions WHERE id = ?");
$stmt->execute(array('red'));
Something like that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.