Question

I am new to Php as well as Yii and you can say that i am a new pilot and yet I am learning flying at A380

issue is that everything is working fine for me until CHAPTER 6 I cannot understand concept of Returning back to the owner and requester dropdowns

I am implementing it side by side and in my case Issue.php did not generated relations ,I just then placed following code

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(
      'owner' => array(self::BELONGS_TO, 'User', 'owner_id'),
      'project' => array(self::BELONGS_TO, 'Project', 'project_id'),
      'requester' => array(self::BELONGS_TO, 'User', 'requester_id'),
    );
  }



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(
            'issues' => array(self::HAS_MANY, 'Issue', 'project_id'),
            'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
        );
    }

if any one can explain working of this i would be great

plus why self:: used?

thanks in advance

Was it helpful?

Solution

How in the world does someone down vote a OP question? That's ignorant. It's a valid question.

Anyway Chapter 6 is a real pain. The writer talks(writes) too much useless info and then fails to fully explain the important info.

I can't really explain the relation other than to say that in Yii this is the syntax so it will automatically understand the data relationships and only return the related data. Without it, it would be retrieving all users in the method getUserOptions but with it, it only retrieves the users related to projects and issues. Or something like that.

I couldn't get mine to populate for the longest because I thought it was supposed to be getting data from trackstar_test but regardless of the config settings we set up in earlier chapters yii is still using trackstar_dev and I wouldn't have known if I hadn't copied the data from test over to dev and all of a sudden everything worked and the dropdowns populated.

I hope something in that is helpful to you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top