|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Db |
|
17 * @subpackage Expr |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: Expr.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 |
|
24 /** |
|
25 * Class for SQL SELECT fragments. |
|
26 * |
|
27 * This class simply holds a string, so that fragments of SQL statements can be |
|
28 * distinguished from identifiers and values that should be implicitly quoted |
|
29 * when interpolated into SQL statements. |
|
30 * |
|
31 * For example, when specifying a primary key value when inserting into a new |
|
32 * row, some RDBMS brands may require you to use an expression to generate the |
|
33 * new value of a sequence. If this expression is treated as an identifier, |
|
34 * it will be quoted and the expression will not be evaluated. Another example |
|
35 * is that you can use Zend_Db_Expr in the Zend_Db_Select::order() method to |
|
36 * order by an expression instead of simply a column name. |
|
37 * |
|
38 * The way this works is that in each context in which a column name can be |
|
39 * specified to methods of Zend_Db classes, if the value is an instance of |
|
40 * Zend_Db_Expr instead of a plain string, then the expression is not quoted. |
|
41 * If it is a plain string, it is assumed to be a plain column name. |
|
42 * |
|
43 * @category Zend |
|
44 * @package Zend_Db |
|
45 * @subpackage Expr |
|
46 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
47 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
48 */ |
|
49 class Zend_Db_Expr |
|
50 { |
|
51 /** |
|
52 * Storage for the SQL expression. |
|
53 * |
|
54 * @var string |
|
55 */ |
|
56 protected $_expression; |
|
57 |
|
58 /** |
|
59 * Instantiate an expression, which is just a string stored as |
|
60 * an instance member variable. |
|
61 * |
|
62 * @param string $expression The string containing a SQL expression. |
|
63 */ |
|
64 public function __construct($expression) |
|
65 { |
|
66 $this->_expression = (string) $expression; |
|
67 } |
|
68 |
|
69 /** |
|
70 * @return string The string of the SQL expression stored in this object. |
|
71 */ |
|
72 public function __toString() |
|
73 { |
|
74 return $this->_expression; |
|
75 } |
|
76 |
|
77 } |