<?php
/**
* This is the model class for table "listinoprezzi".
*
* The followings are the available columns in table 'listinoprezzi':
* @property integer $Id
* @property integer $UserId
* @property integer $IdServizio
* @property integer $IdListino
* @property double $Prezzo
*
* The followings are the available model relations:
* @property Users $user
* @property Servizi $idServizio
* @property Listino $idListino
* @property Listino[] $listinoprezzis
*/
class ListinoPrezzi extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Listino the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'listinoprezzi';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('UserId, IdServizio, IdListino, Prezzo', 'required'),
array('UserId, IdServizio, IdListino', 'numerical', 'integerOnly'=>true),
array('Prezzo', 'numerical'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('Id, UserId, IdServizio, IdListino, Prezzo', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'user' => array(self::BELONGS_TO, 'Users', 'UserId'),
'servizi' => array(self::BELONGS_TO, 'Servizi', 'IdServizio'),
'listini' => array(self::BELONGS_TO, 'Listino', 'IdListino'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'Id' => 'Codice Listino',
'UserId' => 'User',
'IdServizio' => 'Id Servizio',
'IdListino' => 'Id Listino',
'Prezzo' => 'Prezzo',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->join = 'INNER JOIN Servizi ON Servizi.Id=t.Id INNER JOIN Settore ON Settore.Id = Servizi.IdSettore';
$criteria->compare('Id',$this->Id);
$criteria->compare('UserId',Yii::app()->user->id);
$criteria->compare('IdServizio',$this->IdServizio);
$criteria->compare('IdListino',$this->IdListino);
$criteria->compare('Prezzo',$this->Prezzo);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public function getSettore()
{
return $this->servizi->settore->Settore;
}
}
Ho provato anche questa soluzione ma restituisce il seguente errore:
La proprietà "Servizi"."settore" non è definita.
Non so più come procedere!