0

これが私のAlertsモデルです:

<?php
/**
 * This is the model class for table "alerts".
 *
 * The followings are the available columns in table 'alerts':
 * @property string $id
 * @property string $alert_status_id
 * @property string $cmas_regions
 * @property string $alert_type_id
 * @property string $agency_id
 * @property string $incident_at
 * @property string $entered_by_given_name
 * @property string $entered_by_surname
 * @property integer $incident_location_state_reference_code
 * @property string $incident_location_county
 * @property string $incident_location_city
 * @property string $incident_location_latitude
 * @property string $incident_location_longitude
 * @property string $incident_location_address1
 * @property string $incident_location_address2
 * @property string $incident_location_postal_code
 * @property integer $cap_expiration_interval
 * @property string $audio_url
 * @property string $wordpress_post_id
 * @property string $incident_summary
 * @property string $ncic_case_number
 * @property string $local_case_number
 * @property string $information_provider_given_name
 * @property string $information_provider_surname
 * @property string $activation_authorization_officer_given_name
 * @property integer $activation_authorization_officer_surname
 * @property string $activation_authorization_officer_given_rank
 * @property string $activation_authorization_officer_badge_number
 * @property string $activated_at
 * @property string $cancellation_authorization_officer_first_name
 * @property string $cancellation_authorization_officer_surname
 * @property string $cancellation_authorization_officer_rank
 * @property string $cancellation_authorization_officer_badge_number
 *
 * The followings are the available model relations:
 * @property AlertLog[] $alertLogs
 * @property AlertPersons[] $alertPersons
 * @property AlertVehicles[] $alertVehicles
 * @property AlertTypes $alertType
 * @property AlertStatuses $alertStatus
 * @property StatesReference $incidentLocationStateReferenceCode
 * @property Agencies $agency
 * @property CapRegions[] $capRegions
 * @property DistributionLists[] $distributionLists
 * @property SharedAlertRequests[] $sharedAlertRequests
 * @property SharedAlerts[] $sharedAlerts
 */
class Alerts extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Alerts 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 'alerts';
    }

    /**
     * @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('alert_status_id, alert_type_id, agency_id, incident_at, entered_by_given_name, entered_by_surname, incident_summary', 'required'),
            array('incident_location_state_reference_code, cap_expiration_interval, activation_authorization_officer_surname', 'numerical', 'integerOnly'=>true),
            array('alert_status_id, alert_type_id, agency_id, incident_location_postal_code, wordpress_post_id, ncic_case_number', 'length', 'max'=>10),
            array('entered_by_given_name, entered_by_surname, incident_location_county, incident_location_city, incident_location_address1, incident_location_address2, information_provider_given_name, information_provider_surname, activation_authorization_officer_given_name, activation_authorization_officer_given_rank, activation_authorization_officer_badge_number, cancellation_authorization_officer_first_name, cancellation_authorization_officer_surname, cancellation_authorization_officer_rank, cancellation_authorization_officer_badge_number', 'length', 'max'=>63),
            array('incident_location_latitude', 'length', 'max'=>11),
            array('incident_location_longitude, local_case_number', 'length', 'max'=>12),
            array('cmas_regions, audio_url', 'length', 'max'=>255),
            array('activated_at', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, alert_status_id, alert_type_id, agency_id, incident_at, entered_by_given_name, entered_by_surname, incident_location_state_reference_code, incident_location_county, incident_location_city, incident_location_latitude, incident_location_longitude, incident_location_address1, incident_location_address2, incident_location_postal_code, cmas_regions, cap_expiration_interval, audio_url, wordpress_post_id, incident_summary, ncic_case_number, local_case_number, information_provider_given_name, information_provider_surname, activation_authorization_officer_given_name, activation_authorization_officer_surname, activation_authorization_officer_given_rank, activation_authorization_officer_badge_number, activated_at, cancellation_authorization_officer_first_name, cancellation_authorization_officer_surname, cancellation_authorization_officer_rank, cancellation_authorization_officer_badge_number', '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(
            'alertLogs' => array(self::HAS_MANY, 'AlertLog', 'alert_id'),
            'alertPersons' => array(self::HAS_MANY, 'AlertPersons', 'alert_id'),
            'alertVehicles' => array(self::HAS_MANY, 'AlertVehicles', 'alert_id'),
            'alertType' => array(self::BELONGS_TO, 'AlertTypes', 'alert_type_id'),
            'alertStatus' => array(self::BELONGS_TO, 'AlertStatuses', 'alert_status_id'),
            'incidentLocationStateReferenceCode' => array(self::BELONGS_TO, 'StatesReference', 'incident_location_state_reference_code'),
            'agency' => array(self::BELONGS_TO, 'Agencies', 'agency_id'),
            'capRegions' => array(self::MANY_MANY, 'CapRegions', 'alerts_has_cap_regions(alerts_id, cap_regions_id)'),
            'distributionLists' => array(self::MANY_MANY, 'DistributionLists', 'alerts_has_distribution_lists(alert_id, distribution_list_id)'),
            'sharedAlertRequests' => array(self::HAS_MANY, 'SharedAlertRequests', 'alert_id'),
            'sharedAlerts' => array(self::HAS_MANY, 'SharedAlerts', 'alert_id'),
        );
    }

    public function getHour()
    {
        return date('H',strtotime($this->incident_at));
    }

    public function getMinute()
    {
        return date('i',strtotime($this->incident_at));
    }

    public function getDate()
    {
        return date('Y-m-d',strtotime($this->incident_at));
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'alert_status_id' => 'Alert Statuses',
            'cmas_regions' => 'Cmas Regions',
            'alert_type_id' => 'Alert Type',
            'agency_id' => 'Agency',
            'incident_at' => 'Incident At',
            'entered_by_given_name' => 'First Name',
            'entered_by_surname' => 'Last Name',
            'incident_location_state_reference_code' => 'State',
            'incident_location_county' => 'County',
            'incident_location_city' => 'City',
            'incident_location_latitude' => 'Latitude',
            'incident_location_longitude' => 'Longitude',
            'incident_location_address1' => 'Address1',
            'incident_location_address2' => 'Address2',
            'incident_location_postal_code' => 'Postal Code',
            'min'=> 'Minute',
            'cmas_regions' => 'Cmas Regions',
            'cap_expiration_interval' => 'Cap Expiration Interval',
            'audio_url' => 'Audio Url',
            'wordpress_post_id' => 'Wordpress Post',
            'incident_summary' => 'Incident Summary',
            'ncic_case_number' => 'Ncic Case Number',
            'local_case_number' => 'Local Case Number',
            'information_provider_given_name' => 'First Name',
            'information_provider_surname' => 'Last Name',
            'activation_authorization_officer_given_name' => 'First Name',
            'activation_authorization_officer_surname' => 'Last Name',
            'activation_authorization_officer_given_rank' => 'Officer Rank',
            'activation_authorization_officer_badge_number' => 'Officer Badge Number',
            'activated_at' => 'Activated At',
            'cancellation_authorization_officer_first_name' => 'First Name',
            'cancellation_authorization_officer_surname' => 'Last Name',
            'cancellation_authorization_officer_rank' => 'Officer Rank',
            'cancellation_authorization_officer_badge_number' => 'Officer Badge Number',
        );
    }

    /**
     * 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('id',$this->id,true);
        $criteria->compare('alert_status_id',$this->alert_status_id,true);
        $criteria->compare('cmas_regions',$this->cmas_regions,true);
        $criteria->compare('alert_type_id',$this->alert_type_id,true);
        $criteria->compare('agency_id',$this->agency_id,true);
        $criteria->compare('incident_at',$this->incident_at,true);
        $criteria->compare('entered_by_given_name',$this->entered_by_given_name,true);
        $criteria->compare('entered_by_surname',$this->entered_by_surname,true);
        $criteria->compare('incident_location_state_reference_code',$this->incident_location_state_reference_code);
        $criteria->compare('incident_location_county',$this->incident_location_county,true);
        $criteria->compare('incident_location_city',$this->incident_location_city,true);
        $criteria->compare('incident_location_latitude',$this->incident_location_latitude,true);
        $criteria->compare('incident_location_longitude',$this->incident_location_longitude,true);
        $criteria->compare('incident_location_address1',$this->incident_location_address1,true);
        $criteria->compare('incident_location_address2',$this->incident_location_address2,true);
        $criteria->compare('incident_location_postal_code',$this->incident_location_postal_code,true);
        $criteria->compare('cmas_regions',$this->cmas_regions,true);
        $criteria->compare('cap_expiration_interval',$this->cap_expiration_interval);
        $criteria->compare('audio_url',$this->audio_url,true);
        $criteria->compare('wordpress_post_id',$this->wordpress_post_id,true);
        $criteria->compare('incident_summary',$this->incident_summary,true);
        $criteria->compare('ncic_case_number',$this->ncic_case_number,true);
        $criteria->compare('local_case_number',$this->local_case_number,true);
        $criteria->compare('information_provider_given_name',$this->information_provider_given_name,true);
        $criteria->compare('information_provider_surname',$this->information_provider_surname,true);
        $criteria->compare('activation_authorization_officer_given_name',$this->activation_authorization_officer_given_name,true);
        $criteria->compare('activation_authorization_officer_surname',$this->activation_authorization_officer_surname);
        $criteria->compare('activation_authorization_officer_given_rank',$this->activation_authorization_officer_given_rank,true);
        $criteria->compare('activation_authorization_officer_badge_number',$this->activation_authorization_officer_badge_number,true);
        $criteria->compare('activated_at',$this->activated_at,true);
        $criteria->compare('cancellation_authorization_officer_first_name',$this->cancellation_authorization_officer_first_name,true);
        $criteria->compare('cancellation_authorization_officer_surname',$this->cancellation_authorization_officer_surname,true);
        $criteria->compare('cancellation_authorization_officer_rank',$this->cancellation_authorization_officer_rank,true);
        $criteria->compare('cancellation_authorization_officer_badge_number',$this->cancellation_authorization_officer_badge_number,true);

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

次の行でコントローラーで呼び出しています:

$alert_model = new Alerts;
$this->performAjaxValidation(array(
    $alert_model, $agency_model, $victim_model, $suspect_model, $vehicle_model
));

$status = AlertStatuses::model()->find("name='created'");
$alert_model->alert_status_id = $status->id;

これはエラーメッセージです:

エラー: プロパティ "Alerts.alert_status_id" が定義されていません。

どんな助けでも大歓迎です!

4

2 に答える 2

2

アラートテーブルを確認してください。間違いなく、 alert_status_id列が含まれていません。

于 2013-09-02T07:55:23.773 に答える