简体   繁体   English

“'condition'=>'project_id =:projectId',”是什么?“:”的含义是什么?

[英]What is the“'condition'=>'project_id=:projectId',”?what is the meaning of “:”?

I don't know What is the“'condition'=>'project_id=:projectId',”?what is the meaning of “:”? In another word why we should put the “:” in front of the projectId. 我不知道什么是“'condition'=>'project_id =:projectId'”。“:”的含义是什么?换句话说,为什么要在projectId前面加上“:”。 the code is as below. 代码如下。

public function actionIndex()
    {
        $dataProvider=new CActiveDataProvider('Issue',array(
            'criteria'=>array(
                'condition'=>'project_id=:projectId',
                'params'=>array(':projectId'=>$this->_project->id),
            ),
        ));

The way I understand your code snippet, this has to do with escaping query parameters / prepared SQL statements. 我了解您的代码段的方式,这与转义查询参数/准备好的SQL语句有关。 This prevents SQL injection. 这样可以防止SQL注入。 In your example, :projectId in condition is another way of saying "Please replace this :projectId with the escaped value of :projectId ( $this-_project->id ) from params when executing this query". 在您的示例中,处于condition :projectId是另一种说法:“执行此查询时,请从params中使用:projectId$this-_project->id )的转义值替换此:projectId ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM