Showing 481-500 of 652 items.

Relations: BELONGS_TO versus HAS_ONE

Created 15 years ago by Steve Friedl Steve Friedl, updated 13 years ago by Jorgee Jorgee. 9 comments

It's very common to see new Yii users confusing the relations HAS_ONE and BELONGS_TO, and getting it wrong means you won't get proper values back. And though we'll talk about HAS_MANY as well, we're specifically omitting the MANY_MANY relation because it's a whole different animal.

56 0
35
Viewed: 172 765 times
Version: 1.1
Category: FAQs

Configuring controller access rules to default-deny

Created 15 years ago by Steve Friedl Steve Friedl, updated 12 years ago by nsanden nsanden. 3 comments

Starting with the blog tutorial, Yii developers are familiar with the notion of access rules defined in the controller, where the actions are allowed or denied depending on the user's name or role.

class CommentController extends CController {
    public function filters()
    {
        return array( 'accessControl' ); // perform access control for CRUD operations
    }

11 0
12
Viewed: 145 917 times
Version: 1.1
Category: How-tos

Understanding Virtual Attributes and get/set methods

Created 15 years ago by Steve Friedl Steve Friedl, updated 14 years ago by GOsha GOsha. 20 comments

When you define or extend a class, you can create class variables and methods in Yii just like you can in any other PHP system:

class Comment extends CActiveRecord {
    public $helperVariable;
    public function rules() { ... }
    ...
}

and then use them in the obvious way:

$var   = $model->helperVariable;
$rules = $model->rules();

This part everybody understa...

66 0
44
Viewed: 218 804 times
Version: 1.1
Category: Tutorials