Originally Posted by
owen
Data Paging: Page 1, Page 2, Page 3 for the blog posts and probably the comments.
The organisation of the files makes it more manageable for who? could be for the programmer. IMHO putting the related view and controller in the same folder maybe more manageable in some cases especially with lots of views on the same data.
So if the validation is in the model how do you update specific columns?
I have already implemented pagination. You can sign up n try to add as many entries as possible and see. I think i set it at 10 blog posts per page and 20 comments per page for each blog view.
It is a programmer that will be updating the code or implementing new features so "The organisation of the files makes it more manageable for who? could be for the programmer." only makes sense.
For Yii, the convention is that a view maps to a controller action so you will always know where to find what you need. Separating the views from the controller and decoupling it from the data makes the views reusable by other controllers etc...
If you have lots of views on the same data, then you will most likely be rendering each view from a different controller action. A controller action can render any view regardless of where it is placed. Imagine if you have to deal with 30 controllers in a folder, each with at least 3 actions that render a different view. Following the approach from your opinion, you would have 120 files easily in one folder. That's not manageable when you are searching for specific files. When you have a lot of files in a single directory, it is likely that name conflicts may occur then you may end up giving files ugly names like view1.php, view2.php etc...
There are a few ways in which I can do that.
Say I access a record user with fields id, username, password. The record of the id is 1.
I load this record by calling:
PHP Code:
$user = User::model()->findByAttributes(array('id'=>1));
I want to change the password of this record to 12345.
I can do:
PHP Code:
$user->password = '12345';
$user->save();// this will return true or false. The save method will call the validate method. If it fails because of a validation error. You can access the errors in $user->getErrors();
or i can do
PHP Code:
$user->saveAttributes(array('password'=>'12345'));// this will alse return true or false but does not call the validate method.
I use save() when I am saving data that comes from the user.
I use saveAttributes when I am implicitly saving data in the application that will never need validation.