0
좋아요, 그래서 나는 GET HTTP 요청에 응답하는 PHP를 가지고 있습니다. 이 PHP 스크립트는 데이터베이스를 호출하고 일련의 행을 검색합니다. 내가 backbonejs '.fetch'명령을 사용할 때 네 반대로PHP에서 하나의 레코드 만 가져 오는 Backbonejs JOIN
$results = $db->pdoquery("SELECT * FROM posts JOIN users ON posts.user_id=users.id ORDER BY posts.cre DESC LIMIT 4");
$json = json_encode($results);
echo $json;
지금, 그것은 단지, 1 개 첫 번째 레코드를 반환합니다. 내가 잘못 뭘하는지
가$results = $db->pdoquery("SELECT * FROM posts ORDER BY posts.cre DESC LIMIT 4");
$json = json_encode($results);
echo $json;
사람이 설명 할 수 가입
은 내가 네 얻는 PHP 스크립트를 변경하는 경우,하지만 난 내를 잃고있다?
UPDATE : json으로는 PHP 페이지가 인쇄
[{"id":"7","post_name":"title","pretty_url":"link1","preface":"a preface 7","body_text":"a body","feat":"0","img":"\/img\/logo.png","cre":"2012-07-22","modi":"2012-07-18","user_id":"2"},{"id":"6","post_name":"title","pretty_url":"link","preface":"a preface 6","body_text":"a body1","feat":"0","img":"\/img\/logo.png","cre":"2012-07-21","modi":"2012-07-18","user_id":"2"},{"id":"5","post_name":"TestTitle 1","pretty_url":"testlink4","preface":"a preface 5","body_text":"a body 2","feat":"0","img":"\/img\/logo.png","cre":"2012-07-20","modi":"2012-07-16","user_id":"2"},{"id":"4","post_name":"TestTitle 1","pretty_url":"testlink3","preface":"a preface 4","body_text":"a body 3","feat":"0","img":"\/img\/logo.png","cre":"2012-07-19","modi":"2012-07-16","user_id":"2"}]
당신의 DB'SELECT * FROM posts에 직접이 쿼리를 실행하면 어떻게 될까요? posts.user_id = users.id ORDER BY posts.cre DESC LIMIT 4'? – fguillen
쿼리가 4 개의 행을 모두 반환합니다. PHP 페이지는 4 개의 모든 json 배열을 출력합니다. –
결과'json'을 보여줄 수 있습니까? (질문 업데이트) – fguillen