title: Displaying information from two tables in one grid view
body: <p>I have two tables in my database which are needed for in displaying a grid based table of info. Currently the code I have only displays the information for one table (Code below)</p>
  
  <pre><code>&lt;?php $this-&gt;widget('zii.widgets.grid.CGridView', array(
      'id'=&gt;'aux-room-grid',
      'dataProvider'=&gt;$model-&gt;search(),
      'filter'=&gt;$model,
      'columns'=&gt;array(
          'room',
          'capacity',
          array(
              'class'=&gt;'CButtonColumn',
          ),
      ),
  )); ?&gt;
  </code></pre>
  
  <p>I since I have capacity I also would like to get the occupancy, based on how many rows there are associated to a room number which is in my second table. I know that without using PHP this may seem fairly simply, but I am new to Yii and do not understand how I can perform a count on another model. To find the occupancy I would need to use the room# which is the first column of table 1.</p>
  
  <p>Simply put: I need to count() the rows associated with a room number from the first column. I need to display the original tables contents of room and capacity, but with occupancy in between these two columns. How would I do this using Yii?</p>
  
  <p>SQL for the two tables:</p>
  
  <pre><code>CREATE  TABLE IF NOT EXISTS `cs_people`.`aux_room` (
    `room` VARCHAR(20) NOT NULL ,
    `capacity` VARCHAR(20) NULL ,
    PRIMARY KEY (`room`) )
  ENGINE = InnoDB;
  
  CREATE  TABLE IF NOT EXISTS `cs_people`.`room_desk` (
    `userid` VARCHAR(8) NOT NULL ,
    `room` VARCHAR(20) NULL ,
    `desk` VARCHAR(250) NULL ,
    PRIMARY KEY (`userid`) ,
    INDEX `room_desk.room_idx` (`room` ASC) ,
    CONSTRAINT `room_desk.userid`
      FOREIGN KEY (`userid` )
      REFERENCES `cs_people`.`people` (`userid` )
      ON DELETE CASCADE
      ON UPDATE CASCADE,
    CONSTRAINT `room_desk.room`
      FOREIGN KEY (`room` )
      REFERENCES `cs_people`.`aux_room` (`room` )
      ON DELETE CASCADE
      ON UPDATE CASCADE)
  ENGINE = InnoDB;
  </code></pre>