任何人都可以帮我解决错误"数组到字符串转换"在Yii。
我收到此错误"数组到字符串转换"用于以下代码
以下是我的创建代码:
<div class="row">
<?php echo $form->labelEx($model,'emp_reporting'); ?>
<?php
$query="select 0 as emp_id,'ALL' as emp_name UNION select emp_id,emp_name from employee_master";
$result=Yii::app()->db->createCommand($query)->queryAll();
$ld=CHtml::listData($result,'emp_id','emp_name');
$x = array();
if(!$model->isNewRecord )
{
if( $model->emp_reporting != "") {
$query="select emp_id,emp_name from employee_master where emp_id in ($model->emp_reporting)";
$result=Yii::app()->db->createCommand($query)->queryAll();
$selected_list=CHtml::listData($result,'emp_id','emp_name');
foreach ($selected_list as $key => $value)
{
$x[$key]=array("selected"=>"selected");
}
}
}
$this->widget('ext.select2.ESelect2',array(
'model'=>$model,
'attribute'=>'emp_reporting',
'data'=>$ld,
'options'=>array(
'placeholder'=>'Select Employee ..',
),
'htmlOptions'=>array(
'multiple'=>'multiple',
'style'=>'width:200px;',
'options'=>$x,
),
));
?>
<?php echo $form->error($model,'emp_reporting'); ?>
</div>
答案 0 :(得分:0)
嗨我们尝试error
使用array
但不知道string
时,$result
存在syntex
,除listData
之外我无法说出更多} public static array listData(array $models, mixed $valueField, mixed $textField, mixed $groupField='')
就像下面的
$result
因此,根据此array
,model objects
应为$result
。尝试在listdata
上方打印>Mafalda01_2759;barcodelabel=CAR1_01
TACGTAGGGGGCAAGCGTTGTCCGGAATTATTGGGCGTAAAGGGTACGCAGGCGGTTTTTTAAGTCTGATGTGAAATCTC
ATAGCTTAACTATGAGCGGTCATTGGAAACTGGAGAACTTGAGTATAGAAGAGAAGAGTGGAATTCCAAGTGTAGCGGTG
AAATGCGTAGATATTTGGAGGAACACCAGTGGCGAAGGCGACTCTTTGGTCTATTACTGACGCTGAGGTACGAAAGCGTG
GGGAGCAAAC
>Mafalda02_51112;barcodelabel=CAR7_04
TACGTAGGGAGCAAGCGTTGTTCGGATTTACTGGGCGTAAAGGGCGCGTAGGCGGCGCAGTAAGTTACTTGTGAAATCTC
TGGGCTTAACCCAGAACGGCCAAGTAATACTGCAGTGCTAGAGTGCAGAAAGGGCAATCGGAATTCTTGGTGTAGCGGTG
AAATGCGTAGATATCAAGAGGAACACCTGAGGCGAAGGCGGGTTGCTTGTCTGACACTGACGCTGAGGCGCGAAAGCCAG
GGGAGCAAAC
>Mafalda01_145359;barcodelabel=CAC11_86
TACGGAGGATCCAAGCGTTATCCGGAATCATTGGGTTTAAAGGGTCCGTAGGCGGACAATTAAGTCAGCGGTGAAAGTCT
GTAGCTCAACTATAGAACTGCCGTTGATACTGGTTGTCTTGAATCAATGTGAAGTGGCTAGAATATGTGGTGTAGCGGTG
AAATGCTTAGATATCACATAGAACACCGATTGCGAAGGCAGGTCACTAACATTGCATTGACGCTGATGGACGAAAGCGTG
GGGAGCGAAC
>Mafalda02_3119;barcodelabel=CAR4_03
TACGGGGGGTGCGAGCGTTGTCCGGAATCACTGGGCGTAAAGGGCGCGTAGGTGGTCTTATAAGGGTGTGGTGAAAGCCC
GGGGCTCAACCCCGGGTCGGCCGTGCCGACTGTGAGACTAGAGTGCTGTAGGGGCAGGCGGAATTCCGGGTGTAGCGGTG
GAATGCGTAGAGATCCGGAGGAAGACCGGTGGCGAAGGCGGCCTGCTGGGCAGATACTGACACTGAGGCGCGACAGCGTG
GGGAGCAAAC
,看看它有什么价值