Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7752547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:49:42+00:00 2026-06-01T11:49:42+00:00

I has Status Model <?php /** * This is the model class for table

  • 0

I has
Status Model

    <?php

/**
 * This is the model class for table "status".
 *
 * The followings are the available columns in table 'status':
 * @property integer $status_id
 * @property string $message
 * @property string $created
 * @property integer $thumbs_up
 * @property integer $thumbs_down
 * @property string $reply
 * @property integer $user_id
 *
 * The followings are the available model relations:
 * @property Comment[] $comments
 * @property User $user
 * @property ThumbUpDown[] $thumbUpDowns
 */
class Status extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Status 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 'status';
    }

    /**
     * @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('message, created', 'required'),
            array('thumbs_up, thumbs_down, user_id', 'numerical', 'integerOnly' => true),
            array('message', 'length', 'max' => 255),
            array('reply', 'length', 'max' => 45),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('status_id, message, created, thumbs_up, thumbs_down, reply, user_id', '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(
            'comments' => array(self::HAS_MANY, 'Comment', 'status_id'),
            'user' => array(self::BELONGS_TO, 'Register', 'user_id'),
            'thumbUpDowns' => array(self::HAS_MANY, 'Thumb_up_down', 'status_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'status_id' => 'Status',
            'message' => 'Message',
            'created' => 'Created',
            'thumbs_up' => 'Thumbs Up',
            'thumbs_down' => 'Thumbs Down',
            'reply' => 'Reply',
            'user_id' => 'User',
        );
    }

    /**
     * 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('status_id', $this->status_id);
        $criteria->compare('message', $this->message, true);
        $criteria->compare('created', $this->created, true);
        $criteria->compare('thumbs_up', $this->thumbs_up);
        $criteria->compare('thumbs_down', $this->thumbs_down);
        $criteria->compare('reply', $this->reply, true);
        $criteria->compare('user_id', $this->user_id);

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

    public function getUrl() {
        return Yii::app()->createUrl('status', array(
                    'id' => $this->status_id,
                    'title' => $this->message,
                ));
    }

    public function addComment($comment) {
        $comment->status_id = $this->status_id;
        $comment->user_id = Yii::app()->user->id;
        $comment->created = date('Y-m-d H:i:s');
        return $comment->save();
    }



}

Register Model

    <?php

/**
 * This is the model class for table "user".
 *
 * The followings are the available columns in table 'user':
 * @property integer $user_id
 * @property string $username
 * @property string $password
 * @property string $name_first
 * @property string $name_last
 * @property string $email
 * @property string $picture
 * @property integer $active
 * @property string $created
 */
class Register extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Register 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 'user';
    }

    /**
     * @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('username, password, name_first, name_last, email, active, created', 'required'),
            array('username, password, name_first, name_last, email', 'required'),
            array('active', 'numerical', 'integerOnly' => true),
            array('username, password, name_first, name_last', 'length', 'max' => 45),
            array('email', 'length', 'max' => 100),
            array('picture', 'length', 'max' => 255),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('user_id, username, name_first, name_last, email, active', '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(
            'friends' => array(self::HAS_MANY, 'Friend', 'user_id'),
            'friendLists' => array(self::HAS_MANY, 'FriendList', 'user_id'),
            'notifications' => array(self::HAS_MANY, 'Notification', 'user_id'),
            'profiles' => array(self::HAS_MANY, 'Profile', 'user_id'),
            'statuses' => array(self::HAS_MANY, 'Status', 'user_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'user_id' => 'User',
            'username' => 'Username',
            'password' => 'Password',
            'name_first' => 'Name First',
            'name_last' => 'Name Last',
            'email' => 'Email',
            'picture' => 'Picture',
            'active' => 'Active',
            'created' => 'Created',
        );
    }

    /**
     * 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('user_id', $this->user_id);
        $criteria->compare('username', $this->username, true);
        //$criteria->compare('password', $this->password, true);
        $criteria->compare('name_first', $this->name_first, true);
        $criteria->compare('name_last', $this->name_last, true);
        $criteria->compare('email', $this->email, true);
        //$criteria->compare('picture', $this->picture, true);
        $criteria->compare('active', $this->active);
        //$criteria->compare('created', $this->created, true);

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

// encrypt password
    public function beforeSave() {
        $this->created = date('Y-m-d H:i:s');
        $this->password = md5($this->password);
        $this->active = 1;
        $this->picture = '';
        return true;
    }

}

I wanna get username of Status by echo $data->user->username
but I has a error Trying to get property of non-object at $data->user->username
I need your help.
Thank for advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:49:43+00:00Added an answer on June 1, 2026 at 11:49 am

    Looks like user is an array. Try $data->user['username']

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on some Django-code that has a model like this: class Status(models.Model): code
I have a model which has a field status definde as: class Model(models.Model): ...
So my app has the status bar set to be hidden like this in
I have an application that has a status table see Database best practices -
I'm using SQL Server 2008 and I have a table that has a 'Status'
i have 2 tables, users and follows. table follows has a column named status.
In my model example Game, has a status column. But I usually set status
I have a relationship table with followed_id, follower_id, and status. I am using has
I am using rails3 and I have a user model. This model has a
My Persistant model has a 'status' field, which can be 0 or 1. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.