Hi
This method is great and what I was after, except that because I am using
error_reporting (E_ALL|E_STRICT);
I get the following error
Strict Standards: Declaration of XXXXXXX::fetchAll() should be compatible
with that of Zend_Db_Table_Abstract::fetchAll() in
/application/models/XXXXX.php on line 55
What changes need to be made to the declaration in order to make it
compatible?
PHPScriptor wrote:
>
>
> 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 Ingredients 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;
> }
> }
>
>
--
View this message in context:
http://www.nabble.com/My-model-does-not-appear-to-be-working.-tp21986647p22042017.html
Sent from the Zend Framework mailing list archive at Nabble.com.