My favorites | Sign in
yii
Project Home Downloads Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* CDbExpression class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright Copyright &copy; 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

/**
* CDbExpression represents a DB expression that does not need escaping.
* CDbExpression is mainly used in {@link CActiveRecord} as attribute values.
* When inserting or updating a {@link CActiveRecord}, attribute values of
* type CDbExpression will be directly put into the corresponding SQL statement
* without escaping. A typical usage is that an attribute is set with 'NOW()'
* expression so that saving the record would fill the corresponding column
* with the current DB server timestamp.
*
* Starting from version 1.1.1, one can also specify parameters to be bound
* for the expression. For example, if the expression is 'LOWER(:value)', then
* one can set {@link params} to be <code>array(':value'=>$value)</code>.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package system.db.schema
*/
class CDbExpression extends CComponent
{
/**
* @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 {@link expression}, while the values
* are the corresponding parameter values.
* @since 1.1.1
*/
public $params=array();

/**
* Constructor.
* @param string $expression the DB expression
* @param array $params parameters
*/
public function __construct($expression,$params=array())
{
$this->expression=$expression;
$this->params=$params;
}

/**
* String magic method
* @return string the DB expression
*/
public function __toString()
{
return $this->expression;
}
}

Change log

r3527 by qiang.xue on Dec 31, 2011   Diff
1.1.9 release.
Go to: 
Sign in to write a code review

Older revisions

r3515 by mdomba on Dec 28, 2011   Diff
removed 1.0.x reference from
documentation
r2799 by qiang.xue on Jan 1, 2011   Diff
changed copyright year.
r2497 by mdomba on Sep 23, 2010   Diff
Updated PHPDoc @param parameter names
All revisions of this file

File info

Size: 1797 bytes, 61 lines

File properties

svn:keywords
Id
Powered by Google Project Hosting