使用yii框架,不能使用两个表的内部联接在重复的列名中显示值

时间:2014-05-10 06:24:52

标签: php yii

我无法使用yii在具有两个表的内连接的重复列名中显示值。 我的视图页面是advance_search_detail.php和控制器sitecontroller.php.I得到错误'Property“Job.Ltitle”未定义“。在视图页面中没有ltitle我得到了搜索结果。

Controller是sitecontroller.php

public function actionadvance_search_result()
{
  $title=$_GET['title'];
  $experience=$_GET['experience'];
  $location=$_GET['location'];
  $category=$_GET['category'];
  $salary_min=$_GET['salary_min'];
  $salary_max=$_GET['salary_max'];

  $criteria = new CDbCriteria();
  $criteria->select = 't.title, location.title as  Ltitle,  t.key_skills, t.description,   t.no_vacancy, t.experience, t.company_name, t.salary';
  $criteria->join = 'INNER JOIN location ON t.location_id = location.id';
  if($experience!="")
  {
    $criteria->addCondition("(title like '%$title%' or  key_skills like '%$title%') and   (   experience like '%$experience%')");    
  }
  if($location!="")
  {
    $criteria->addCondition("location_id like '%$location%'");
  }

  if($category!="")
  {
    $criteria->addCondition("category_id like '%$category%'");
  }
  if($salary_min!="" && $salary_max!="")
  {
    $criteria->addCondition("salary >= '$salary_min' and salary <=  '$salary_max'");
  }

  $count=Job::model()->count($criteria);
  $pages=new CPagination($count);
  $pages->pageSize=2;
  $pages->applyLimit($criteria);
  $model=Job::model()->findAll($criteria);
  $number_rec=count($model);
  if($number_rec<=0)
  {
    $this->render('search_result1',array('model' =>$model));
  }
  else
  {
    $this->render('advance_search_result',array('model' =>$model,'pages' => $pages));
  }
}

我的观看页面是advance_search_result.php

<div>
  <div>
    <h1>Search Results</h1>
    <ul style="list-style:none; ">
    <?php
      foreach($model as $models)  
      {
        $job_id=$models->id;
      ?>
      <li><p><?php //echo $models->title; ?>
          <?php echo CHtml::link($models->title, array('site/advance_search_detail', 'job_id'=>$job_id,'status'=>0)); ?></p>
          <p><?php echo CHtml::link($models->Ltitle); ?></p>
          <p><?php echo $models->company_name; ?></p>
          <p><?php echo $models->description; ?></p>
          <p>Keyskill:<?php echo $models->key_skills; ?><p>
      </li></br>
    <?php
      }
     ?>
    </ul>    
    <p><?php $this->widget('CLinkPager', array('pages' => $pages)) ?></p>   
  </div>
</div>

有人对这些问题提出任何建议吗?

0 个答案:

没有答案