Welcome Guest, Not a member yet? Register   Sign In
Quick question regarding where_in/where_not_in Active Record
#5

[eluser]xzela[/eluser]
Hmmm...

I would use joins and transitional tables for a feature like that.
You'll need to create a table which holds the link between the images and the tags:
Code:
CREATE TABLE trans_table (
   id INT,
   image_id INT,
   tag_id INT,
   );
Then to see which tags are applied to each image you could run a query that would look something like this:
Code:
SELECT
   image.image_id,
   tag.tag_id,
   tag.tag_name
FROM
   image
   LEFT JOIN trans_table ON image.image_id = trans_table.image_id
   LEFT JOIN tag ON trans_table.tag_id = tag.tag_id
WHERE
   image.image_id = $image_id;

This will return all of the tags (names, ids) that applied to a specific image.

Let me know if you have any questions.


Messages In This Thread
Quick question regarding where_in/where_not_in Active Record - by El Forum - 04-19-2009, 09:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB