littlevisuals Posted September 25, 2009 Share Posted September 25, 2009 Hi everyone, I have a database with the looks like the following; I have created the model below <?php /** * Description of gallery * * @author lv */ class Model_DbTable_Artist extends Zend_Db_Table_Abstract { protected $_name = 'artist'; } class Model_DbTable_Image extends Zend_Db_Table_Abstract { protected $_name = 'image'; } class Model_DbTable_Category extends Zend_Db_Table_Abstract { protected $_name = 'category'; protected $_referenceMap = array( 'ArtistCategory' => array( 'columns' => 'artist_id' , 'category_id', 'refTableClass' => 'Artist', 'Category', 'refColumns' => 'artist_id' , 'category_id', ), 'ImageCategory' => array( 'columns' => 'image_id' , 'category_id', 'refTableClass' => 'Category', 'Image', 'refColumns' => 'image_id' , 'category_id', ), 'Artist' => array( 'columns' => 'artist_id', 'refTableClass' => 'Image', 'refColumns' => 'image_id' ) ); } Is the right way to join tables in zend??? Quote Link to comment https://forums.phpfreaks.com/topic/175446-solved-joing-tables-using-a-classs-in-the-zend-framework/ Share on other sites More sharing options...
448191 Posted September 26, 2009 Share Posted September 26, 2009 Can't do it. I am a big fan of ZF, but Zend_Db_Table sucks. Try Doctrine instead. Quote Link to comment https://forums.phpfreaks.com/topic/175446-solved-joing-tables-using-a-classs-in-the-zend-framework/#findComment-925488 Share on other sites More sharing options...
RichardRotterdam Posted September 26, 2009 Share Posted September 26, 2009 I agree with that try Doctrine (or Propel) you might get addicted. I think I read one of 448191's blog articles that coverd this exact subject. Other then that I think your db design could use some work. For example why not have a foreign key in your image table instead of joining artist_id with image_id? Quote Link to comment https://forums.phpfreaks.com/topic/175446-solved-joing-tables-using-a-classs-in-the-zend-framework/#findComment-925509 Share on other sites More sharing options...
gluck Posted October 2, 2009 Share Posted October 2, 2009 I think you should redesign your database. You can easily eliminate the two category_cross tables. Just add a foreign key in the artist and image tables as someone suggested. Actually you need 3 master tables - Artist, Image and Category. One cross table where you associate artists with images. Add category id just to image master table. Also I would keep image urls should in images because an artist will have multiple images. Quote Link to comment https://forums.phpfreaks.com/topic/175446-solved-joing-tables-using-a-classs-in-the-zend-framework/#findComment-929274 Share on other sites More sharing options...
littlevisuals Posted October 18, 2009 Author Share Posted October 18, 2009 Thanks a bunch! Got the db sorted now gluck! Quote Link to comment https://forums.phpfreaks.com/topic/175446-solved-joing-tables-using-a-classs-in-the-zend-framework/#findComment-939372 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.