微信公众号在yii2框架中的坑

可以设置多次表单提交,在每个控制器的开头最好都设置

 public $enableCsrfValidation = false;

syntax error, unexpected 'endif' (T_ENDIF)

找了半天发现是html页面中中写成了根本不是不认识endif标签或者是if后边的:以及括号不匹配等等问题

yii2写sql语句中的in

 public function getcatesByIds($bc_id,$select="BC_ID,BC_NAME,BC_CODE,BC_LEVEL,P_BC_ID,PATH_ID,PATH_NAME",$isArray = true)
{
    if($isArray)
    {
        return $this->find()->select($select)->where(array('IN','BC_ID', $bc_id))->andWhere('STATUS = :STATUS', [':STATUS'=>1])->asArray()->all();
    }else{
        return $this->find()->select($select)->where(array('IN','BC_ID', $bc_id))->andWhere('STATUS = :STATUS', [':STATUS'=>1])->all();
    }
}

记住用all(),而且是where(array('IN','BC_ID', $bc_id))
而不是where(['in','BC_ID', $bc_id])还用one()

return $this->find()->select($select)->where(['in','BC_ID', $bc_id])->andWhere('STATUS = :STATUS', [':STATUS'=>1])->one();

这样只能查询出来一条数据,sql语句是bc_id=$bcId,而不是in

你可能感兴趣的:(微信公众号在yii2框架中的坑)