0

私は Yii の初心者です Yii の CGridView の上部に新しく挿入されたエントリを表示したいのですが、それがどのように可能かわかりませんか?

 public function search()
    {
        $criteria=new CDbCriteria;
        $criteria->alias = "jb";
        $criteria->compare('title', $this->title, true);
        $criteria->compare('notes', $this->notes, true);
        $criteria->compare('createdon', $this->createdon, true);
        $criteria->compare('expirydate', $this->expirydate, true);
        $criteria->join= 'INNER JOIN company co ON (co.companyid=jb.companyid)';
        return new CActiveDataProvider(get_class($this), array(
                'criteria' => $criteria,
        ));
4

1 に答える 1

0

結合にリレーションを使用しないのはなぜですか?

$criteria=new CDbCriteria;
    $criteria->alias = "jb";
    $criteria->compare('title', $this->title, true);
    $criteria->compare('notes', $this->notes, true);
    $criteria->compare('createdon', $this->createdon, true);
    $criteria->compare('expirydate', $this->expirydate, true);
    $criteria->with('company');
    $criteria->together=>true;

    return new CActiveDataProvider(get_class($this), array(
            'criteria' => $criteria,
    ));

jbモデルのdefaultScope

public function defaultScope()
{
    $alias = $this->getTableAlias(false,false);
    return array(
        'order'=>"`$alias`.`id` DESC",
    );
}
于 2013-10-03T08:49:38.517 に答える