123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * Database expressions can be used to add unescaped SQL fragments to a
- * [Database_Query_Builder] object.
- *
- * For example, you can use an expression to generate a column alias:
- *
- * // SELECT CONCAT(first_name, last_name) AS full_name
- * $query = DB::select(array(DB::expr('CONCAT(first_name, last_name)'), 'full_name')));
- *
- * @package Fuel/Database
- * @category Base
- * @author Kohana Team
- * @copyright (c) 2009 Kohana Team
- * @license http://kohanaphp.com/license
- */
- namespace Fuel\Core;
- class Database_Expression
- {
- // Raw expression string
- protected $_value;
- /**
- * Sets the expression string.
- *
- * $expression = new Database_Expression('COUNT(users.id)');
- *
- * @return void
- */
- public function __construct($value)
- {
- // Set the expression string
- $this->_value = $value;
- }
- /**
- * Get the expression value as a string.
- *
- * $sql = $expression->value();
- *
- * @return string
- */
- public function value()
- {
- return (string) $this->_value;
- }
- /**
- * Return the value of the expression as a string.
- *
- * echo $expression;
- *
- * @return string
- * @uses Database_Expression::value
- */
- public function __toString()
- {
- return $this->value();
- }
- }
|