我有这个搜索表单:
RUN /bin/bash -l -c 'echo export SECRET_KEY_BASE="$(openssl rand -hex 64)" > /etc/profile.d/docker_init.sh'
这个控制器动作:
<form method="GET" action="<?php echo Yii::$app->request->baseUrl;?>/telephone/search/">
<input type="text" name="name" placeholder="Name or Telephone no." required>
<input type="submit" class="btn-btn-default" value="search"></form>
和这个观点:
public function actionSearch()
{
$request = Yii::$app->request;
$name=$request->get('name');
$search=Telephone::find()->where('Name LIKE :substr', array(':substr' => '%$name%'))->all();
return $this->render('search',['search'=>$search]);
}
但不显示搜索记录。
答案 0 :(得分:0)
定义时有单引号:substr $ name
请将其更改为"%$name%"