Solved

Zend Db Table Select not Selecting All Rows

Posted on 2008-06-24
3
1,539 Views
Last Modified: 2011-08-18
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

0
Comment
Question by:sean-keys
  • 2
3 Comments
 
LVL 1

Expert Comment

by:kkretsch
ID: 21863703
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.
0
 

Accepted Solution

by:
sean-keys earned 0 total points
ID: 21867973
I think my problem lies in the select.

Displaying Short View

Warning: Invalid argument supplied for foreach() in /home/sean/Zend/workspaces/psi-inv-zf/application/default/views/scripts/index/showall.phtml on line 8
Nickname       Serial       
SELECT "t_sites"."name" FROM "t_sites"




 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');
		echo $select->__toString();
	//	$this->view->items = $items->fetchAll($select);

Open in new window

0
 

Author Comment

by:sean-keys
ID: 21869541
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

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cpanel file manager 8 42
How is this connection happening? 3 20
php help 34 58
check mysql insert 12 28
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question