Solved

SELECT statement in Zend_Framework

Posted on 2008-06-18
2
360 Views
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>

<table>

<tr>

     <th>nickname</th>

     <th>serial</th>

     <th>&nbsp;</th>

</tr>

<?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; ?>

</table>

Open in new window

0
Comment
Question by:sean-keys
2 Comments
 
LVL 5

Accepted Solution

by:
Alex-w474 earned 500 total points
ID: 21818492
Look for Zend_Db_Select examples in manual: http://framework.zend.com/manual/en/zend.db.select.html
Or use select object derived from the table: http://framework.zend.com/manual/en/zend.db.table.html#zend.db.table.fetch-all
$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

0
 

Author Closing Comment

by:sean-keys
ID: 31468618
Thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
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…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

17 Experts available now in Live!

Get 1:1 Help Now