Size: 1778
Comment:
|
Size: 3476
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 31: | Line 31: |
Require local | Require all granted |
Line 64: | Line 64: |
== Validation rules ActiveRecord CModel == http://www.yiiframework.com/doc/guide/1.1/en/form.model#declaring-validation-rules We specify the validation rules in the rules() method which should return an array of rule configurations. || '''Alias''' || '''Class''' || ||boolean || CBooleanValidator || ||captcha || CCaptchaValidator || ||compare || CCompareValidator || ||email || CEmailValidator || ||date || CDateValidator || ||default || CDefaultValueValidator || ||exist || CExistValidator || ||file || CFileValidator || ||filter || CFilterValidator || ||in || CRangeValidator || ||length || CStringValidator || ||match || CRegularExpressionValidator || ||numerical || CNumberValidator || ||required || CRequiredValidator || ||type || CTypeValidator || ||unique || CUniqueValidator || ||url || CUrlValidator || {{{#!highlight php public function rules() { return array( array('username, password', 'required'), array('rememberMe', 'boolean'), array('password', 'authenticate'), ); } }}} == Relations ActiveRecord == http://www.yiiframework.com/doc/guide/1.1/en/database.arr#declaring-relationship Override the relations() method of CActiveRecord. Types relationship: * self::BELONGS_TO * self::HAS_MANY * self::HAS_ONE * self::MANY_MANY {{{#!highlight php public function relations() { return array( 'posts'=>array(self::HAS_MANY, 'Post', 'author_id'), 'profile'=>array(self::HAS_ONE, 'Profile', 'owner_id'), ); } }}} == CActiveRecord == http://www.yiiframework.com/doc/api/1.1/CActiveRecord |
Yii
Yii is a high-performance PHP framework best for developing Web 2.0 applications.
Slackware installation
http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x
- cd ~/Downloads
wget https://github.com/yiisoft/yii/releases/download/1.1.15/yii-1.1.15.022a51.tar.gz
- cp yii-1.1.15.022a51.tar.gz /vars/www/htdocs
- cd /vars/www/htdocs
- tar xvzf yii-1.1.15.022a51.tar.gz
- cd yii-1.1.15.022a51
- chown apache * -R
- chmod 755 /etc/rc.d/rc.httpd
- vim /etc/httpd/httpd.conf
<IfModule dir_module> DirectoryIndex index.html index.php </IfModule> LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so Include /etc/httpd/mod_php.conf # enable the php module
- vim /etc/httpd/vhosts.conf
<VirtualHost *:80> ServerName localhostyii DocumentRoot "/var/www/htdocs/yii-1.1.15.022a51" <Directory "/var/www/htdocs/yii-1.1.15.022a51"> Require all granted AllowOverride all </Directory> </VirtualHost>
- vim /etc/hosts
127.0.0.1 localhostyii
- vim /etc/httpd/php.ini
date.timezone="Europe/Lisbon"
- vim /var/www/htdocs/yii-1.1.15.022a51/demos/blog/.htaccess
Options +FollowSymLinks IndexIgnore */* RewriteEngine on RewriteBase /demos/blog # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php
- vim blog/protected/config/main.php
'urlManager'=>array( 'showScriptName'=>false,
- /etc/rc.d/rc.httpd start
Validation rules ActiveRecord CModel
http://www.yiiframework.com/doc/guide/1.1/en/form.model#declaring-validation-rules
We specify the validation rules in the rules() method which should return an array of rule configurations.
Alias |
Class |
boolean |
CBooleanValidator |
captcha |
CCaptchaValidator |
compare |
CCompareValidator |
CEmailValidator |
|
date |
CDateValidator |
default |
CDefaultValueValidator |
exist |
CExistValidator |
file |
CFileValidator |
filter |
CFilterValidator |
in |
CRangeValidator |
length |
CStringValidator |
match |
CRegularExpressionValidator |
numerical |
CNumberValidator |
required |
CRequiredValidator |
type |
CTypeValidator |
unique |
CUniqueValidator |
url |
CUrlValidator |
Relations ActiveRecord
http://www.yiiframework.com/doc/guide/1.1/en/database.arr#declaring-relationship
Override the relations() method of CActiveRecord.
Types relationship:
- self::BELONGS_TO
- self::HAS_MANY
- self::HAS_ONE
- self::MANY_MANY