-
Book Overview & Buying
-
Table Of Contents
Yii Application Development Cookbook - Second Edition - Second Edition
Active Record implementation in Yii is very powerful and has many features. One of these features is event-like methods , which you can use to preprocess model fields before putting them into the database or getting them from a database, as well as deleting data related to the model, and so on.
In this recipe, we will linkify all URLs in the post text and we will list all existing Active Record event-like methods.
Create a new application by using yiic webapp as described in the official guide at the following URL:
http://www.yiiframework.com/doc/guide/en/quickstart.first-app
Set up a database connection and create a table named post as follows:
DROP TABLE IF EXISTS `post`; CREATE TABLE IF NOT EXISTS `post` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `title` VARCHAR(255) NOT NULL, `text` TEXT NOT NULL, PRIMARY KEY (`id`) );
Generate the Post model using Gii
Add the following method to protected/models...
Change the font size
Change margin width
Change background colour