Hi All;
I've just started using Zend Framework and having a hard time getting used to this new way of doing things. I'm a bit confused about how to register databases with the registry and putting things all together. I can query tables fine and put the results into my view if I use the table model, that is make the table a class and refer to it as a object through Zend_Table_class. This is fine for querys with one table but I think for joins its better to use their SQL builder interface. So if I put in my bootstrap file: // load configuration $config = new Zend_Config_Ini('./application/config.ini', 'general'); $registry = Zend_Registry::getInstance(); $registry->set('config', $config); // setup database $db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray()); Zend_Db_Table::setDefaultAdapter($db); Zend_Registry::set('db', $db); ///// Can I just use in my controller : $db = Zend_Registry::get('db'); $select = $db->select(); $select->distinct() ->from( 'course') ->join(array( 'user'), 'course.teacherID = user.id') ; $data = $db->fetchAll($select); $this->view->data = $data;// This doesn't work and I'm not sure why. This works with the model: $dbuser = new User(); $this->view->dbuser = $dbuser->fetchAll();
_______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php