さて、GET HTTP リクエストに応答する php があります。この PHP スクリプトはデータベースを呼び出し、一連の行を取得します。
$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;
backbonejs の '.fetch' コマンドを使用すると、最初のレコードが 4 つではなく 1 つだけ返されます。
PHPスクリプトを変更すると、4つすべてが得られますが、JOINを失う必要があります
$results = $db->pdoquery("SELECT * FROM posts ORDER BY posts.cre DESC LIMIT 4");
$json = json_encode($results);
echo $json;
誰かが私が間違っていることを説明できますか?
UPDATE : PHP ページが出力する JSON
[{"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"}]