RhythmicDevils wrote:
>
> function indexAction()
> {
> $this->view->title = "Ingredient";
> $ingredients = new Ingredients();
> $this->view->ingredients = $ingredients->fetchAll();
> }
>
> That I would get all the ingredients and all their related data. Something
> similar to running the SQL:
>
> SELECT * FROM ingredients, ingredient_types
> WHERE ingredients.ingredient_type_id = ingredient_types.id
> class IngredientTypes extends Zend_Db_Table_Abstract
> {
> protected $_name = 'ingredient_types';
> }
> class Ingredients extends Zend_Db_Table_Abstract
> {
> protected $_name = 'ingredients';
> }
>
No the framework doesn't know about the presence of the foreign key. Maybe
you can define it with "referencetables". Look at the tutorial how to build
them up. However... even then, I don't think you get all the data just by a
fetchAll().
This is my suggestion:
class IngredientTypes extends Zend_Db_Table_Abstract
{
protected $_name = 'ingredients';
public function fetchAll($select = null) {
if(is_null($select))
$select = parent::select();
$select->setIntegrityCheck(false);
$select->from($this->_name, array('*'))
->joinLeft('ingredients','ingredients.ingredient_type_id=ingredient_types.id',array('*'));
$results = parent::fetchAll($select);
return $results;
}
}
-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context:
http://www.nabble.com/My-model-does-not-appear-to-be-working.-tp21986647p21991370.html
Sent from the Zend Framework mailing list archive at Nabble.com.