Skip to main content

yii - using CActiveDataProvider to display group by MYSQL record -


please need quick right now. here question

i have table several columns. using yii framework display data want group record in way

column 1 column2 column3 column4

1 2 3 4

80 3 1 100

30 3 1 60

50 3 0 10

90 2 3 40

100 2 1 80

so want query table display column2 , column3, group column2. having issues that, column2 returns 2,2 - 3,3 , group record column3 under each of duplicated column2

my result should display in way:

........................................................................ column2 -- 2 .1 .3 ......................................................................... column2 -- 3 .0 .1

controller::

protected function displaybycategory() { //$model = new mymodel; $criteria= new cdbcriteria(); $criteria->distinct = true; $criteria->group = 'column2,column3'; $criteria->order = 'column2'; //$dataprovider=new cactivedataprovider('mymodel' ); $dataprovider=new cactivedataprovider('mymodel', array( 'criteria'=>$criteria, 'pagination'=>false, )); $this->renderpartial('application.views.competency.ctype',array( 'dataprovider'=>$dataprovider, )); } 

my view:

<ul id="example1" class="accordion"> <li> <h3><?php echo chtml::link(chtml::encode($data->column2)); ?></h3> <div class="panel loading"> <h4><?php echo chtml::link(chtml::encode($data->column3)); ?></h4> </div> </li> </ul> 

yii - using cactivedataprovider display group mysql record - stack overflow

learn, share, build

each month, on 50 million developers come stack overflow learn, share knowledge, , build careers.

join world’s largest developer community.

sign up

please need quick right now. here question

i have table several columns. using yii framework display data want group record in way

column 1 column2 column3 column4

1 2 3 4

80 3 1 100

30 3 1 60

50 3 0 10

90 2 3 40

100 2 1 80

so want query table display column2 , column3, group column2. having issues that, column2 returns 2,2 - 3,3 , group record column3 under each of duplicated column2

my result should display in way:

........................................................................ column2 -- 2 .1 .3 ......................................................................... column2 -- 3 .0 .1

controller::

protected function displaybycategory() { //$model = new mymodel; $criteria= new cdbcriteria(); $criteria->distinct = true; $criteria->group = 'column2,column3'; $criteria->order = 'column2'; //$dataprovider=new cactivedataprovider('mymodel' ); $dataprovider=new cactivedataprovider('mymodel', array( 'criteria'=>$criteria, 'pagination'=>false, )); $this->renderpartial('application.views.competency.ctype',array( 'dataprovider'=>$dataprovider, )); } 

my view:

<ul id="example1" class="accordion"> <li> <h3><?php echo chtml::link(chtml::encode($data->column2)); ?></h3> <div class="panel loading"> <h4><?php echo chtml::link(chtml::encode($data->column3)); ?></h4> </div> </li> </ul> 
share|improve question

your answer

 
discard

posting answer, agree privacy policy , terms of service.

browse other questions tagged or ask own question.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -