did you mean getAttributes()? Below is the output … I really don’t understand where it gets DisplayName from… see the full model code below …
Results from var_dump
array(9) { ["SpeciesID"]=> string(1) "8" ["SpeciesGroupID"]=> string(1) "1" ["SpeciesName"]=> string(6) "aaaaaa" ["Targeted"]=> string(1) "1" ["ETPSpecies"]=> string(1) "1" ["Bait"]=> string(1) "1" ["DateTimeUpdated"]=> NULL ["ChangedByPersonID"]=> NULL ["DisplayName"]=> string(14) "aaaaaa (Crabs)" }
Species Model
<?php
/**
* This is the model class for table "Species".
*
* The followings are the available columns in table 'Species':
* @property string $SpeciesID
* @property string $SpeciesGroupID
* @property string $SpeciesName
* @property boolean $Targeted
* @property boolean $ETPSpecies
* @property boolean $Bait
* @property string $DateTimeUpdated
* @property string $ChangedByPersonID
*
* The followings are the available model relations:
* @property WildlifeInteraction[] $wildlifeInteractions
* @property HaulBait[] $haulBaits
* @property LandedCatch[] $landedCatches
* @property CatchUnitSpeciesWeight[] $catchUnitSpeciesWeights
* @property FishingActivityGearCatch[] $fishingActivityGearCatches
* @property SpeciesGroup $speciesGroup
* @property Person $changedByPerson
* @property FishingActivityGearReturn[] $fishingActivityGearReturns
* @property FishingActivityTargetSpecies[] $fishingActivityTargetSpecies
*/
class Species extends CActiveRecord
{
public $speciesGroup_title;
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Species the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
function beforeSave() {
var_dump ($this->getAttributes());
die();
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'Species';
}
/**
* @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('SpeciesGroupID, SpeciesName, Targeted, ETPSpecies, Bait', 'required'),
array('SpeciesGroupID, ChangedByPersonID', 'length', 'max'=>18),
array('SpeciesName', 'length', 'max'=>255),
array('DateTimeUpdated', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('SpeciesID, SpeciesGroupID, SpeciesName, Targeted, ETPSpecies, Bait, DateTimeUpdated,
ChangedByPersonID, speciesGroup_title', '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(
'wildlifeInteractions' => array(self::HAS_MANY, 'WildlifeInteraction', 'SpeciesID'),
'haulBaits' => array(self::HAS_MANY, 'HaulBait', 'SpeciesID'),
'landedCatches' => array(self::HAS_MANY, 'LandedCatch', 'SpeciesID'),
'catchUnitSpeciesWeights' => array(self::HAS_MANY, 'CatchUnitSpeciesWeight', 'SpeciesID'),
'fishingActivityGearCatches' => array(self::HAS_MANY, 'FishingActivityGearCatch', 'SpeciesID'),
'speciesGroup' => array(self::BELONGS_TO, 'SpeciesGroup', 'SpeciesGroupID'),
'changedByPerson' => array(self::BELONGS_TO, 'Person', 'ChangedByPersonID'),
'fishingActivityGearReturns' => array(self::HAS_MANY, 'FishingActivityGearReturn', 'SpeciesID'),
'fishingActivityTargetSpecies' => array(self::HAS_MANY, 'FishingActivityTargetSpecies', 'SpeciesID'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'SpeciesID' => 'Species',
'SpeciesGroupID' => 'Species Group',
'speciesGroup_title' => 'Species Group',
'SpeciesName' => 'Species Name',
'Targeted' => 'Targeted',
'ETPSpecies' => 'Etpspecies',
'Bait' => 'Bait',
'DateTimeUpdated' => 'Date Time Updated',
'ChangedByPersonID' => 'Changed By Person',
);
}
/**
* 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->compare('SpeciesID',$this->SpeciesID,true);
$criteria->compare('SpeciesGroupID',$this->SpeciesGroupID,true);
$criteria->compare('SpeciesName',$this->SpeciesName,true);
$criteria->compare('Targeted',$this->Targeted);
$criteria->compare('ETPSpecies',$this->ETPSpecies);
$criteria->compare('Bait',$this->Bait);
$criteria->compare('DateTimeUpdated',$this->DateTimeUpdated,true);
$criteria->compare('ChangedByPersonID',$this->ChangedByPersonID,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}