Modules
Database_Expression
extends Kohana_Database_Expression
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')));
More examples are available on the Query Builder page
Class declared in MODPATH/database/classes/database/expression.php on line 3.
Properties
protected
$_value
Methods
public __construct( ) (defined in Kohana_Database_Expression)
Sets the expression string.
$expression = new Database_Expression('COUNT(users.id)');
Return Values
void
Source Code
public function __construct($value)
{
// Set the expression string
$this->_value = $value;
}
public __toString( ) (defined in Kohana_Database_Expression)
Return the value of the expression as a string.
echo $expression;
Tags
Return Values
string
Source Code
public function __toString()
{
return $this->value();
}
public value( ) (defined in Kohana_Database_Expression)
Get the expression value as a string.
$sql = $expression->value();
Return Values
string
Source Code
public function value()
{
return (string) $this->_value;
}