|
|||
|
I'm currenlt trying to do something like this:
Model - products.php ----------------------------------------------------------------------------------------- class products extends Zend_Db_Table {} $products = new products(); $db = Zend::registry('db'); $select = $db->select(); $select->from('products', '*'); $select->joinLeft('productFormat', 'productFormat.id = products.productFormatId', '*'); return $products->fetchAll($select); ------------------------------------------------------------------------------------------ products table has a FK named: productFormatId productFormat table has an id PK I need to find out how to use and extend zend_db_table so that I can still use the $products->fetchAll() within the controller but it will return the joined table. I'm currently using thye V.7 framework using what I've got currently - I receive the following error message: Warning: PDO::quote() expects parameter 1 to be string |
|
||||
|
Hello,
Question. Is not easier to use rather something more simple rather than going to Zend_DB_Table ? Cause i would personally go better for this: $field1 = $db->quote($field1); $field2 = $db->quote($field2); $sql = "SELECT * FROM `myTbl` ..... LEFT JOIN ..........................."; $result $db->fetchAll($sql); Try this way and see what's happening.
__________________
Zend Framework Tutorials | Zend Framework Forums | Zend Framework IRC Channel | | Zend Framework Resources | CoreShifter | Microsoft Forums | Microsoft Links | Microsoft Books |
|
|||
|
I've done this:
in the controller: ----------------------------------------------- $db = Zend::registry('db'); $sql = $db->select(); $sql->from('products', '*'); $sql->join('product_format', 'products.product_format_id = product_format.id', '*'); $view->productsList = $db->fetchAll($sql); ----------------------------------------------- in the view: ----------------------------------------------- <?php foreach($this->productsList as $product) : ?> <option value="<?php echo $this->escape($product->id);?>"><?php echo $this->escape($product->productDesc) . ' - ' . $this->escape($product->productFormatDesc);?></option> <?php endforeach; ?> ----------------------------------------------- and I'm receiving an error: Trying to get property of non-object in product_search.php on line 11 I just can't figure it out - where am I going wrong? |
|
|||
|
it's cool - I don't know how I missed that
<?php foreach($this->productsList as $product) : ?> <option value="<?php echo $this->escape($product['product_code']);?>"><?php echo $this->escape($product['product_desc']) . ' - ' . $this->escape($product['product_format_desc']);?></option> <?php endforeach; ?> is there any way that you can get around the name clashes for ID on both tables? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|