You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.0 KiB
60 lines
1.0 KiB
7 years ago
|
<?php
|
||
|
/**
|
||
|
* Part of the Fuel framework.
|
||
|
*
|
||
|
* @package Fuel
|
||
|
* @version 1.8
|
||
|
* @author Fuel Development Team
|
||
|
* @license MIT License
|
||
|
* @copyright 2010 - 2016 Fuel Development Team
|
||
|
* @copyright 2008 - 2009 Kohana Team
|
||
|
* @link http://fuelphp.com
|
||
|
*/
|
||
|
|
||
|
namespace Fuel\Core;
|
||
|
|
||
|
class Database_Expression
|
||
|
{
|
||
|
// Raw expression string
|
||
|
protected $_value;
|
||
|
|
||
|
/**
|
||
|
* Sets the expression string.
|
||
|
*
|
||
|
* $expression = new Database_Expression('COUNT(users.id)');
|
||
|
*
|
||
|
* @param string $value expression string
|
||
|
*/
|
||
|
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();
|
||
|
}
|
||
|
|
||
|
}
|