diff --git a/src/Db/MysqliDb.php b/src/Db/MysqliDb.php index 9d3c91a..be69e50 100644 --- a/src/Db/MysqliDb.php +++ b/src/Db/MysqliDb.php @@ -64,7 +64,7 @@ public function query($query, $params = array()) if ($this->throwException) { throw new \RuntimeException('DB error in : ' . $query); } else { - trigger_error('DB error in : ' . $query, E_USER_ERROR); + trigger_error('DB error' . ' ' . $this->conn->error . ' ' . _('in') . ': ' . $query, E_USER_ERROR); die(_('DB error') . ' ' . $this->conn->error . ' ' . _('in') . ': ' . $query); } } diff --git a/src/User/User.php b/src/User/User.php index 6a716c8..250a2f8 100644 --- a/src/User/User.php +++ b/src/User/User.php @@ -19,7 +19,7 @@ public function __construct( public function findUserIdByNumber($number) { - $result = $this->db->query("SELECT userId FROM users WHERE userNumber='$number'"); + $result = $this->db->query("SELECT userId FROM users WHERE number='$number'"); if ($result->num_rows == 1) { return $result->fetch_assoc()["userId"]; } diff --git a/tests/User/UserTest.php b/tests/User/UserTest.php index 2707617..1b4d70e 100644 --- a/tests/User/UserTest.php +++ b/tests/User/UserTest.php @@ -16,7 +16,7 @@ public function testFindUserIdByNumberReturnsUserId() $dbMock = $this->createMock(DbInterface::class); $dbMock->expects($this->exactly(2)) ->method('query') - ->with("SELECT userId FROM users WHERE userNumber='{$userNumber}'") + ->with("SELECT userId FROM users WHERE number='{$userNumber}'") ->willReturnOnConsecutiveCalls( new MysqliResult(1, [['userId' => $expectedUserId]]), new MysqliResult(0, [])