Link to home
Start Free TrialLog in
Avatar of sean-keys
sean-keys

asked on

Zend Db Table Select not Selecting All Rows

Hi

I finally figured out how to do joins with zend_db_table_select.  My problem now is that its not returning all rows. Or so I think.

I get the following error message.

Fatal error: Uncaught exception 'Zend_Db_Table_Row_Exception' with message 'Specified column "nickname" is not in the row'


public function showallAction()
    {
    	$this->view->title = "Showing All PSI Inventory";
	    $items = new Items();
		$select = $items->select()->setIntegrityCheck(false);
		$select->join('t_sites', 't_items.site_id = t_sites.id', 'name');
		$this->view->items = $items->fetchAll($select);
	//	echo $select->		    
    }
 
 
 
<?php foreach($this->items as $item) : ?>
<tr>
     <td><?php echo $this->escape($item->nickname);?></td>
     <td><?php echo $this->escape($item->serial);?></td>
     <td>
          <a href="<?php echo $this->url(array('controller'=>'index',
              'action'=>'edit', 'id'=>$item->id));?>">Edit</a>
          <a href="<?php echo $this->url(array('controller'=>'index',
              'action'=>'delete', 'id'=>$item->id));?>">Delete</a>
     </td>
</tr>
<?php endforeach; ?>

Open in new window

Avatar of kkretsch
kkretsch
Flag of Germany image

Did you already have alook into the $item's content?
just do a print_r($item) to look for the names of the returned columns.
ASKER CERTIFIED SOLUTION
Avatar of sean-keys
sean-keys

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sean-keys
sean-keys

ASKER

This works
 public function showallAction()
    {
    	$this->view->title = "Showing All PSI Inventory";
	    $items = new Items();
		$select = $items->select()->setIntegrityCheck(false);
		$select->from('t_items');
		$select->join('t_sites', 't_items.site_id = t_sites.id', 'name AS sitename' );
		$select->join('t_status', 't_items.status_id = t_status.id', 'name AS statusname');
		//TODO Select only columns need by show all shortview
		//echo $select->__toString();
		$this->view->items = $items->fetchAll($select);

Open in new window