Friday 15 August 2014

php - PDO query assistance -


So im has moved to my questions about the PDO, and I am learning step by step.

I bought the test and error, that unlike normale mysql_, you can not do this at one time at a time etc.

Then im trying to get the expected results of joining tables in a question.

The following query works

  $ data = $ conn- & gt; Query (select 'nieuws.id, nieuws.titel, nieuws.intro, nieuws.inhoud, nieuws.datum, nieuws.auteur, nieuws.categorie, nieuws.tags, nieuws.plaatje, nieuws.plaatje_url, nieuws.mp3, nieuws .mp3_url, nieuws.youtube, nieuws.youtube_url, reacties.id, reacties.nieuwsid, combining on nieuws inner reacties from reacties.submitter, responses by reacties.reactie Nieuws.id = Reaction. Anaiuviseed Ardiaar. Anaiuvisiaidi Diissi LIMIT 3 ');   

However, it only returns one entry, I want it all "Nieuws" Entrys, and Corrosponding "Reacties" query (based on ID) to return

translation Dutch to English words: Nieuws = news, reacties = comment

so it ID 1, for example, must meet with all data and must obtain nieuwsid1 data. And then do this for all IDX results

  $ data = $ conn- & gt; Query ('Select * by nieuws command ID ID DESC limit 3');   

Receives all the news, but I do not have any feedback, and ever since the article etc

  foreach ($ line as $ Data)   

Loop I can not start a second foreach right?

Well, you're using a INNER JOIN , which Only gives entries from Table A, which are entries in Table B, so if there is no comment in the "News" item, then it will not return.

What do you want LEFT OUTER JOIN .

No comments:

Post a Comment