upd: database.repo.user (added backquotes around table and column names)

This commit is contained in:
xdrm-brackets 2017-11-26 11:54:49 +01:00
parent 4ebd101e6c
commit 8ccc05e280
1 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@
public function getAll(){ public function getAll(){
/* (1) Statement */ /* (1) Statement */
$st = $this->pdo->query("SELECT * FROM user ORDER BY username ASC"); $st = $this->pdo->query("SELECT * FROM `user` ORDER BY `username` ASC");
/* (2) Fetched data */ /* (2) Fetched data */
return $st->fetchAll(); return $st->fetchAll();
@ -34,7 +34,7 @@
public function getById(int $id_user){ public function getById(int $id_user){
/* (1) Prepare Statement */ /* (1) Prepare Statement */
$pst = $this->pdo->prepare("SELECT * FROM user WHERE id_user = :id_user LIMIT 1"); $pst = $this->pdo->prepare("SELECT * FROM `user` WHERE `id_user` = :id_user LIMIT 1");
/* (2) Bind variables */ /* (2) Bind variables */
$pst->bindParam(':id_user', $id_user, \PDO::PARAM_INT); $pst->bindParam(':id_user', $id_user, \PDO::PARAM_INT);
@ -59,7 +59,7 @@
public function getByMail(String $mail){ public function getByMail(String $mail){
/* (1) Prepare Statement */ /* (1) Prepare Statement */
$pst = $this->pdo->prepare("SELECT * FROM user WHERE mail = :mail LIMIT 1"); $pst = $this->pdo->prepare("SELECT * FROM `user` WHERE `mail` = :mail LIMIT 1");
/* (2) Bind variables */ /* (2) Bind variables */
$pst->bindParam(':mail', $mail, \PDO::PARAM_STR, 50); $pst->bindParam(':mail', $mail, \PDO::PARAM_STR, 50);
@ -84,7 +84,7 @@
public function getByUsername(String $username){ public function getByUsername(String $username){
/* (1) Prepare Statement */ /* (1) Prepare Statement */
$pst = $this->pdo->prepare("SELECT * FROM user WHERE username = :username LIMIT 1"); $pst = $this->pdo->prepare("SELECT * FROM `user` WHERE `username` = :username LIMIT 1");
/* (2) Bind variables */ /* (2) Bind variables */
$pst->bindParam(':username', $username, \PDO::PARAM_STR, 20); $pst->bindParam(':username', $username, \PDO::PARAM_STR, 20);
@ -109,7 +109,7 @@
public function getByToken(String $token){ public function getByToken(String $token){
/* (1) Prepare Statement */ /* (1) Prepare Statement */
$pst = $this->pdo->prepare("SELECT * FROM user WHERE token is not NULL AND token = :token LIMIT 1"); $pst = $this->pdo->prepare("SELECT * FROM `user` WHERE `token` is not NULL AND `token` = :token LIMIT 1");
/* (2) Bind variables */ /* (2) Bind variables */
$pst->bindParam(':token', $token, \PDO::PARAM_STR, 128); $pst->bindParam(':token', $token, \PDO::PARAM_STR, 128);
@ -137,7 +137,7 @@
$hash = \secure_hash($password, $id_user, 'user-pass'); $hash = \secure_hash($password, $id_user, 'user-pass');
/* (2) Prepare Statement */ /* (2) Prepare Statement */
$pst = $this->pdo->prepare("SELECT * FROM user WHERE id_user = :id_user AND pass = :pass LIMIT 1"); $pst = $this->pdo->prepare("SELECT * FROM `user` WHERE `id_user` = :id_user AND `pass` = :pass LIMIT 1");
/* (3) Bind variables */ /* (3) Bind variables */
$pst->bindParam(':id_user', $id_user, \PDO::PARAM_INT); $pst->bindParam(':id_user', $id_user, \PDO::PARAM_INT);