Yii Framework Forum: $Criteria Problem Z Id - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

$Criteria Problem Z Id Rate Topic: -----

#1 User is offline   mentorq 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 105
  • Joined: 26-June 13

Posted 30 July 2013 - 05:53 AM

Witam, mam problem ze znalezieniem rozwiązania na mój problem. Chce do view dodać kolumny z innej tabeli gdzie id = id akutalnej grupy.

model:
public function getRelatedMember ()
        {
           $criteria=new CDbCriteria;
           $criteria->addCondition("group_id = 1"); //Tutaj zamiast z palca, żeby generowało poprawne id
           //$criteria->addCondition("enquiry_date > strtotime('now')");
           $model = Member::model()->findAll($criteria);
            
            
            
           //$model=Member::model()->findAll(array('order'=>'id'));
           $out=CHtml::listData($model,'id','firstname');
           $wynik = '<ul>';
           foreach($out as $key=>$value) { 
                $wynik .= sprintf('<li>%s</li>', CHtml::link($value, array('member/view', 'id' => $key)));
                
           }
           $wynik .= '</ul>';
           return $wynik;
        }


view:
<?php 
$this->widget('zii.widgets.CDetailView', array(
	'data' => $model,
	'attributes'=>array(
		'id',
		'title',
                array(
                        'name'=>'member',
                        'type'=>'html',
                        'value'=>$model->getRelatedMember(),
          )      
	),
)); ?>


Dzięki z góry za pomoc ;)
0

#2 User is offline   mentorq 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 105
  • Joined: 26-June 13

Posted 30 July 2013 - 07:25 AM

Już wiem...
public function getRelatedMember ($id)
        {
           $criteria=new CDbCriteria;
           $criteria->addCondition("group_id = $id");
         ...
         }



'value'=>$model->getRelatedMember($model->id),


i śmiga.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users