Jump to content
Larry Ullman's Book Forums

beentold

Members
  • Posts

    2
  • Joined

  • Last visited

beentold's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hello Larry. Thanks for taking the time to reply to my post! Yes, I think that's it. Basically, the way I understand it, CActiveDataProvider in EmployeeController.php on line 126 gets the employee table as a whole and then passes it on to the index view. $dataProvider=new CActiveDataProvider('Employee'); $this->render('index',array( 'dataProvider'=>$dataProvider, )); Which in turn passes it on to the _view widget. <?php $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$dataProvider, 'itemView'=>'_view', )); ?> In _view.php the list of employees is generated. The information from $dataProvider is now in $data. And on lines 12 and 13 the departmentId is displayed. <b><?php echo CHtml::encode($data->getAttributeLabel('departmentId')); ?>:</b> <?php echo CHtml::encode($data->departmentId); ?> I would like to lookup the department name and display that instead. Is there a way I can manipulate $dataProvider in the controller to include the departmentName (from the table department) instead of departmentId (from the table employee) - or in addition to it?
  2. Hello everyone! First of all, Larry, thank you for the Yii tutorial!!! I have just gone through it and I ran into a little bit of a dead end. In the Employee controller (line 126) it says: $dataProvider=new CActiveDataProvider('Employee'); I would like to add something like this: SELECT name FROM department WHERE id = employee.departmentId And then pass the department.name to the view instead of the employee.departmentId. I'm sorry if this is total BS. I'm a noob in MVC (and PHP/MySQL too, to be honest). I'm sure I could just find out how to write a proper MySQL query and pass it on in an array, but I think there must be a "simpler" (or more elegant) way to do this. Thanks in advance for any replies!
×
×
  • Create New...