hi am trying to run a sql query but it gives this error, i have reservations column in stores table and a reservations table which has firstname,lastname or email:
"SQLSTATE[42000]: Syntax or access violation: 1064 you have an error in your SQL syntax; 'FROM reservations R LEFT JOIN 'at line 11"
code:
public function getReservationData($store = null, $limit = 10, $offset = 1) { $em = $this->getEntityManager(); $offset = ($offset -1) * $limit; $query = "SELECT R.FirstName as firstName, R.LastName as lastName, R.Email as email, FROM reservaions R LEFT JOIN stores S ON s.id = R.store WHERE s.id = :store AND S.reservation = 1"; $stmt->$this->getEntityManager()->getConnection->prepare($query); $stmt->$bindParam(':store', $store); $stmt->execute(); $result[] = $stmt->fetch(); return $result; }
Advertisement
Answer
R.Email as email,
remove the “,” and that will solve your problem