Class yii\db\Expression
Inheritance | yii\db\Expression » yii\base\Object |
---|---|
Implements | yii\base\Configurable |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/Expression.php |
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.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$expression | string | The DB expression | yii\db\Expression |
$params | array | List of parameters that should be bound for this expression. | yii\db\Expression |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Object |
__construct() | Constructor. | yii\db\Expression |
__get() | Returns the value of an object property. | yii\base\Object |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Object |
__set() | Sets value of an object property. | yii\base\Object |
__toString() | String magic method | yii\db\Expression |
__unset() | Sets an object property to null. | yii\base\Object |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Object |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Object |
className() | Returns the fully qualified name of this class. | yii\base\Object |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Object |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\Object |
init() | Initializes the object. | yii\base\Object |
Property Details
The DB expression
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.
Method Details
Constructor.
void __construct( $expression, $params = [], $config = [] ) | ||
$expression | string | The DB expression |
$params | array | Parameters |
$config | array | Name-value pairs that will be used to initialize the object properties |
String magic method
string __toString( ) | ||
return | string | The DB expression |
---|