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.
61 lines
1.5 KiB
61 lines
1.5 KiB
14 years ago
|
<?php
|
||
|
/**
|
||
|
* @link http://www.yiiframework.com/
|
||
12 years ago
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||
14 years ago
|
* @license http://www.yiiframework.com/license/
|
||
|
*/
|
||
|
|
||
12 years ago
|
namespace yii\db;
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Expression represents a DB expression that does not need escaping or quoting.
|
||
|
* When an Expression object is embedded within a SQL statement or fragment,
|
||
|
* it will be replaced with the [[expression]] property value without any
|
||
|
* DB escaping or quoting. For example,
|
||
|
*
|
||
|
* ~~~
|
||
|
* $expression = new Expression('NOW()');
|
||
|
* $sql = 'SELECT ' . $expression; // SELECT NOW()
|
||
|
* ~~~
|
||
|
*
|
||
|
* An expression can also be bound with parameters specified via [[params]].
|
||
|
*
|
||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||
|
* @since 2.0
|
||
|
*/
|
||
13 years ago
|
class Expression extends \yii\base\Object
|
||
14 years ago
|
{
|
||
|
/**
|
||
|
* @var string the DB expression
|
||
|
*/
|
||
|
public $expression;
|
||
|
/**
|
||
|
* @var array list of parameters that should be bound for this expression.
|
||
|
* The keys are placeholders appearing in [[expression]] and the values
|
||
|
* are the corresponding parameter values.
|
||
|
*/
|
||
|
public $params = array();
|
||
|
|
||
|
/**
|
||
|
* Constructor.
|
||
|
* @param string $expression the DB expression
|
||
|
* @param array $params parameters
|
||
13 years ago
|
* @param array $config name-value pairs that will be used to initialize the object properties
|
||
14 years ago
|
*/
|
||
13 years ago
|
public function __construct($expression, $params = array(), $config = array())
|
||
14 years ago
|
{
|
||
|
$this->expression = $expression;
|
||
|
$this->params = $params;
|
||
13 years ago
|
parent::__construct($config);
|
||
14 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* String magic method
|
||
|
* @return string the DB expression
|
||
|
*/
|
||
|
public function __toString()
|
||
|
{
|
||
|
return $this->expression;
|
||
|
}
|
||
12 years ago
|
}
|