File indexing completed on 2024-05-12 06:02:26

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Db
0017  * @subpackage Expr
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 
0024 /**
0025  * Class for SQL SELECT fragments.
0026  *
0027  * This class simply holds a string, so that fragments of SQL statements can be
0028  * distinguished from identifiers and values that should be implicitly quoted
0029  * when interpolated into SQL statements.
0030  *
0031  * For example, when specifying a primary key value when inserting into a new
0032  * row, some RDBMS brands may require you to use an expression to generate the
0033  * new value of a sequence.  If this expression is treated as an identifier,
0034  * it will be quoted and the expression will not be evaluated.  Another example
0035  * is that you can use Zend_Db_Expr in the Zend_Db_Select::order() method to
0036  * order by an expression instead of simply a column name.
0037  *
0038  * The way this works is that in each context in which a column name can be
0039  * specified to methods of Zend_Db classes, if the value is an instance of
0040  * Zend_Db_Expr instead of a plain string, then the expression is not quoted.
0041  * If it is a plain string, it is assumed to be a plain column name.
0042  *
0043  * @category   Zend
0044  * @package    Zend_Db
0045  * @subpackage Expr
0046  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0047  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0048  */
0049 class Zend_Db_Expr
0050 {
0051     /**
0052      * Storage for the SQL expression.
0053      *
0054      * @var string
0055      */
0056     protected $_expression;
0057 
0058     /**
0059      * Instantiate an expression, which is just a string stored as
0060      * an instance member variable.
0061      *
0062      * @param string $expression The string containing a SQL expression.
0063      */
0064     public function __construct($expression)
0065     {
0066         $this->_expression = (string) $expression;
0067     }
0068 
0069     /**
0070      * @return string The string of the SQL expression stored in this object.
0071      */
0072     public function __toString()
0073     {
0074         return $this->_expression;
0075     }
0076 
0077 }