SELECT statement in Zend_Framework

Posted on 2008-06-18
Last Modified: 2013-12-12
I have th following code that will display all the rows in a table.  I want to use a custom select statement to display data from more than one table.   How can I do this with zend_db_table ? Or do i need to use another class?

$this->view->title = "Showing All";

		$items = new Items();

		$this->view->items = $items->fetchAll();	





require_once 'Zend/Db/Table/Abstract.php';


class Items extends Zend_Db_Table_Abstract {


	 * The default table name 


	protected $_name = 't_items';




<p><a>Displaying Short View</a></p>







<?php foreach($this->items as $item) : ?>


     <td><?php echo $this->escape($item->nickname);?></td>

     <td><?php echo $this->escape($item->serial);?></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>



<?php endforeach; ?>


Open in new window

Question by:sean-keys

Accepted Solution

Alex-w474 earned 500 total points
ID: 21818492
Look for Zend_Db_Select examples in manual:
Or use select object derived from the table:
$table = new Bugs();

$select = $table->select();

$select->where('bug_status = ?', 'NEW')

       ->join('accounts', 'accounts.account_name = bugs.reported_by')

       ->where('accounts.account_name = ?', 'Bob');

$rows = $table->fetchAll($select);

Open in new window


Author Closing Comment

ID: 31468618

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now