I
I
Ivan Komarov2018-06-27 09:58:38
MySQL
Ivan Komarov, 2018-06-27 09:58:38

How to make a selection from the database if the column is named KEY?

Oru Chot.
Opencart has a setting table that stores store parameters. Each parameter is assigned a key.
The problem is that the key column is named with the reserved word KEY and I can't make a fetch using PDO because the query fails. What can be done in this situation?

$stmt = $this->dbh->prepare("SELECT * FROM z_setting WHERE key=:key");
    $stmt->bindParam(':key', $key, PDO::PARAM_STR);  
    $stmt->execute();
    return $stmt->fetchAll();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-06-27
@FreeTibet

$stmt = $this->dbh->prepare("SELECT * FROM z_setting WHERE `key`=:key");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question