我有以下视图代码用于用户的搜索关键字输入:
<?php echo CHtml::beginForm(Yii::app()->createUrl('home/search'),'get',array('accept-charset'=>'UTF-8',
'enctype'=>'multipart/form-data'));?>
<div class="search-box">
<div class="input-box left">
<input type="text" name="q" id="t-search" class="txt-box"
placeHolder="<?php echo Yii::t('website', 'enter.search.keyword.here'); ?>"/>
</div>
<div class="left">
<input type="submit" id="b-search" class="btn main-bg" value="GO"/>
</div>
</div>
<?php echo CHtml::endForm();?>
在控制器中,我有以下搜索操作:
public function actionSearch($q)
{
Yii::app()->theme = "website";
$this->layout = '//layouts/main';
$this->pageTitle = Yii::t('website', 'search.result');
$result = Yii::app()->db->createCommand('call search_procedure('."'".$q."'".')')->queryAll() ;
$this->render('search', array('result'=>$result));
}
代码与英语完美配合,但是当用户想要使用阿拉伯语搜索时,如果我们在搜索操作中使用var_dump($q); exit();
命令,$q
变量设置为 ØμØ ̄Ø§Ø 未知字符,所以我无法在搜索过程中使用此参数值。
谁能帮忙?谢谢。
我已经找到了以下问题的解决方案:1)首先,我的PC Windows操作系统中的系统本地设置存在问题,因此我将其更改为阿拉伯国家之一。2) 其次,search_procedure 中的 IN 参数类型有问题,所以我将其更改为 varchar(20)。