:catch되지 않은 예외 'PDOException'[42000] : 구문 오류 또는 액세스 위반 : 1064 [해결] 내 쿼리입니다
public function getAllServices($start, $limit)
{
$services = array();
$q = $this->init()->prepare('SELECT id, service_title, time_add FROM services ORDER BY id DESC LIMIT :start, :limit');
$q->execute(array(":start" => $start, ":limit" => $limit));
while ($values = $q->fetchAll(PDO::FETCH_ASSOC))
$services[] = $values;
return $services;
}
오류 메시지 :
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '10''
편집 : 그게 내 문제를 해결했습니다 :
$q = $this->init()->prepare("SELECT id, service_title, time_add FROM services ORDER BY id DESC LIMIT :start, :limit");
$q->bindParam(':start', $start, PDO::PARAM_INT);
$q->bindParam(':limit', $limit, PDO::PARAM_INT);
$q->execute();
연결 변수가 전역 변수가 아닙니다. – Enijar
나는 변화를 시도한다 : 시작과 : 다른 이름으로 제한하지만 결과가 없다. –
글쎄, 나는 오늘 무언가를 배웠다 @ ВълкоКалъчев --- 그것이 해결되었다는 것을 알기에 다행이다. 당신은 자신의 대답을 게시 할 수 있다는 것을 알고 있습니다. –