代码之家  ›  专栏  ›  技术社区  ›  Red Bottle

yii2中Gii生成的搜索模型中的语法错误

  •  0
  • Red Bottle  · 技术社区  · 7 年前

    我为一个名为 vast_table 然而,我在Gii生成的模型中有一个语法错误,这是非常好的。 错误是:

    PHP Parse Error – yii\base\ErrorException
    
    syntax error, unexpected ']'
    

    我的搜索模型如下所示:

            $query->andFilterWhere(['like', 'Ad', $this->Ad])
            ->andFilterWhere(['like', 'Collapse', $this->Collapse])
            ->andFilterWhere(['like', 'CloseLinear', $this->CloseLinear])
            ->andFilterWhere(['like', 'Skip', $this->Skip])
            ->andFilterWhere(['like', 'Played10%', $this->Played10%])
            ->andFilterWhere(['like', 'Played30%', $this->Played30%])
            ->andFilterWhere(['like', 'Played40%', $this->Played40%])
            ->andFilterWhere(['like', 'Played60%', $this->Played60%]);
    

    1 回复  |  直到 7 年前
        1
  •  1
  •   csminb    7 年前

    modulo

    虽然您可以将db列定义为 Played60% ,php不允许在变量名中放置特殊字符

    您可以将这些列重命名为 Played60p 或者手动调整gii生成的模型属性,使其语法正确。

    此外,还有模式设计 guideline