我的3个表关联如下:
我想写成这样的SQL语句
mysql> select url_info.id,url_info.url_name,url_info.url_path,url_info.url_style
,url_info.created,url_info.modify,url_info.cid,group_concat(tag_name),url_info.s
tatus,category.category_name from url_info,category,tags_info where cid=category
.id and cid=952 and find_in_set(tags_info.id,tag_ids) group by url_info.id order
by url_info.id;
在控制层中我是这么写的
$dataProvider=new CActiveDataProvider('url_info', array(
'criteria'=>array(
//'select'=>'t.id,t.url_name,t.url_path,t.url_style,t.created,t.modify,t.cid,group_concat(tags_info.tag_name),t.status,category.category_name',
'with'=>array('category','tags_info'),
'condition'=> 'cid=category.id and cid=:cid and find_in_set(tags_info.id,tag_ids)',
'params'=>'cid=category.id',
'group'=>'t.id',
'order'=>'t.id desc ',
),
'pagination'=>array(
'pageSize'=>self::PAGE_SIZE,
),
));
显示层中:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'category.category_name',
'url_name',
'url_path',
[b] 'group_concat(tags_info.tag_name)',//这边有问题[/b]
//'created',
'status',
'clicks',
/*
'url_style',
'modify',
*/
array(
'class'=>'CButtonColumn',
),
),
))
抛出的错误是:The column must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.
Source File
D:\www\www\htdocs\yii\framework\zii\widgets\grid\CGridView.php(236)
00224: foreach($this->columns as $column)
00225: $column->init();
00226: }
00227:
00228: /**
00229: * Creates a {@link CDataColumn} based on a shortcut column specification string.
00230: * @param string the column specification string
00231: * @return CDataColumn the column instance
00232: */
00233: protected function createDataColumn($text)
00234: {
00235: if(!preg_match('/^([\w\.]+)(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />\w*))?(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/sad.gif' class='bbc_emoticon' alt=':(' />.*))?$/',$text,$matches))
00236: throw new CException(Yii::t('zii','The column must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'));
00237: $column=new CDataColumn($this);
00238: $column->name=$matches[1];
00239: if(isset($matches[3]))
00240: $column->type=$matches[3];
00241: if(isset($matches[5]))
00242: $column->header=$matches[5];
00243: return $column;
00244: }
00245:
00246: /**
00247: * Registers necessary client scripts.
00248: */
不知道如何写! 请教大家!