Logo F2FInterview

Zend Framework Interview Questions

Q   |   QA

You must sign a CLA before Zend Framework can accept any content that constitutes intellectual property. This includes anything that could carry a copyright or be patented. This includes code, patches, tests, documentation, and even proposals submitted on our wiki. You do not need to submit a CLA to report a bug or make a feature request in our issue tracker, or to ask a question on the mailing lists. You can include code in emails to the mailing lists to illustrate your words, but your code cannot be incorporated into Zend Framework unless it is submitted under the terms of the CLA.

There are lots of ways to contribute to Zend Framework. Many major features are contributed to ZF through our proposal process. Most code contributors also commit bug fixes and tests. Another valuable form of contribution is manual translation and other forms of documentation. Contributors may also invest their time in updating the wiki or adding, commenting on, and voting on issues in our issue tracker. No matter how you plan to contribute, the best place to get started is our contributor guide.

<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category Zend
 * @package Zend_Db
 * @subpackage Table
 * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
 * @license http://framework.zend.com/license/new-bsd New BSD License
 */

Zend::loadClass("Zend_Db_Table");

class Zend_Db_Table_Orm extends Zend_Db_Table {

//per http://framework.zend.com/wiki/display/ZFMLGEN/mail/1625
protected $_rowClassName = 'Zend_Db_Table_Row';
protected $_rowsetClassName = 'Zend_Db_Table_Rowset';
protected $_dirs = null; // to support db_row classes in different directories

/**
* Fetches all rows.
*
* Honors the Zend_Db_Adapter fetch mode.
*
* @param string|array $where An SQL WHERE clause.
* @param string|array $order An SQL ORDER clause.
* @param int $count An SQL LIMIT count.
* @param int $offset An SQL LIMIT offset.
* @return mixed The row results per the Zend_Db_Adapter fetch mode.
*/
public function fetchAll($where = null, $order = null, $count = null,
$offset = null)
{

$className = $this->_rowsetClassName;
Zend::loadClass($className, $this->_dirs);

return new $className(array(
'db' => $this->_db,
'table' => $this,
'data' => $this->_fetch('All', $where, $order, $count, $offset),
));
}

/**
* Fetches one row.
*
* Honors the Zend_Db_Adapter fetch mode.
*
* @param string|array $where An SQL WHERE clause.
* @param string|array $order An SQL ORDER clause.
* @return mixed The row results per the Zend_Db_Adapter fetch mode.
*/
public function fetchRow($where = null, $order = null)
{
$className = $this->_rowClassName;
Zend::loadClass($className, $this->_dirs);

return new $className(array(
'db' => $this->_db,
'table' => $this,
'data' => $this->_fetch('Row', $where, $order, 1),
));
}

/**
* Fetches a new blank row (not from the database).
*
* @return _rowClassName class
*/
public function fetchNew()
{
$keys = array_keys($this->_cols);
$vals = array_fill(0, count($keys), null);

$className = $this->_rowClassName;
Zend::loadClass($className, $this->_dirs);

return new $className(array(
'db' => $this->_db,
'table' => $this,
'data' => array_combine($keys, $vals),

));
}

}

?> 

Actually, by default, if your expression includes parentheses, Zend_Db_Select will cast the statement appopriately. However, if it does not, or you are having problems, you can use Zend_Db_Expr to explicitly create the expression:

/* Build the SQL:
 * SELECT p."product_id", p.cost * 1.08 AS cost_plus_tax
 * FROM "products" AS p
 */
$select = $db->select()
        ->from(array('p' => 'products'),
               array(
                   'product_id',
                   'cost_plus_tax' => new Zend_Db_Expr('p.cost * 1.08'),
                ));

You're probably looking for decorators. All forms and form elements in Zend_Form use decorators to render their output.

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: