Here is my database structure (simplified):
TABLE properties
id (PK, INT, AUTO INC)
prop_vebraid (INT)
TABLE images
id (PK, INT, AUTO INC)
image_url (VARCHAR)
prop_vebraid (INT)
file_index (INT)
I am using MySQL database with MyISAM format, so I don’t have any foreign keys in the database.
I’m currently outputting all fields from the properties table in my Controller $models=Property::model()->findAll($criteria);
I now need to extend this so that it returns the matching image_url from the images table. The matching field in both tables is prop_vebraid. As one property can have many images, it must also check that file_index in the images table is 1.
Does anyone have any idea how I can do this, as I’m having some difficulty doing it.