public function actionAr() { $actors = Actor::model()->findAll(array('with' => 'films', 'order' => 't.first_name, t.last_name, films.title')); echo "<ol>"; foreach ($actors as $actor) { echo "<li>"; echo $actor->first_name . ' ' . $actor->last_name; echo "<ol>"; foreach ($actor->films as $film) { echo "<li>"; echo $film->title; echo "</li>"; } echo "</ol>"; echo "</li>"; } echo "</ol>"; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Actor the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Actor::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/* @var $this UseCaseController */ /* @var $model UseCase */ /* @var $form CActiveForm */ ?> <div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'use-case-form', 'enableAjaxValidation' => false)); ?> <!-- DropDown to be copied --> <div style='display:none'> <?php echo $form->dropDownList(Actor::model(), 'id_actor', CHtml::listData(Actor::model()->findAll(), 'id_actor', 'description')); ?> </div> <!-- end DropDown to be copied--> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'parent'); ?> <?php
echo $form->labelEx($model, 'last_update'); ?> <?php echo $form->textField($model, 'last_update'); ?> <?php echo $form->error($model, 'last_update'); ?> </div><!-- row --> <label><?php echo GxHtml::encode($model->getRelationLabel('actors')); ?> </label> <?php echo $form->checkBoxList($model, 'actors', GxHtml::encodeEx(GxHtml::listDataEx(Actor::model()->findAllAttributes(null, true)), false, true)); ?> <label><?php echo GxHtml::encode($model->getRelationLabel('categories')); ?> </label> <?php echo $form->checkBoxList($model, 'categories', GxHtml::encodeEx(GxHtml::listDataEx(Category::model()->findAllAttributes(null, true)), false, true)); ?> <label><?php echo GxHtml::encode($model->getRelationLabel('inventories')); ?> </label> <?php echo $form->checkBoxList($model, 'inventories', GxHtml::encodeEx(GxHtml::listDataEx(Inventory::model()->findAllAttributes(null, true)), false, true)); ?>
function getActors($model) { $actors = array(); $string = ''; foreach (UseCaseEvent::model()->findAll("use_case = {$model->id_use_case}") as $events) { $actor = $events->primary_actor; if (!isset($actors[$actor])) { $actors[$actor] = 0; } else { $actors[$actor]++; } } foreach ($actors as $idA => $t) { $string .= Actor::model()->findByPk($idA)->description . ", "; } return $string != '' ? substr($string, 0, -2) : $string; }