Jump to content

Getting a MySQL JOIN into a nice PHP array structure


EvanAgee

Recommended Posts

So I've got a content management system that stores page content/data in one table and assets (images, videos, etc) in a separate table. I know I can use a JOIN to get all of the data with one query, but I'm looking to match the resulting output with the PHP array I'm currently using to distribute the resulting content to the Smarty template.

 

Currently I get all of the page data and set that array to $page. Then I do a second query to get all of the assets and set that resulting array to $page["assets"].

 

So, I'm wondering if there's a good way to take my new JOIN query and structure that result so rather than having one large 1 dimensional array I have an array that's setup with all of the results from the assets table as an element of the content table result array.

 

Hope I'm making sense :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.