mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-06 14:19:23 +08:00
@ -9,15 +9,20 @@ namespace yii\db;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
*
|
||||
* ```php
|
||||
* $expression = new Expression('NOW()');
|
||||
* $sql = 'SELECT ' . $expression; // SELECT NOW()
|
||||
* $now = (new \yii\db\Query)->select($expression)->scalar(); // SELECT NOW();
|
||||
* echo $now; // prints the current date
|
||||
* ```
|
||||
*
|
||||
* Expression objects are mainly created for passing raw SQL expressions to methods of
|
||||
* [[Query]], [[ActiveQuery]], and related classes.
|
||||
*
|
||||
* An expression can also be bound with parameters specified via [[params]].
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
|
Reference in New Issue
Block a user