Yii 1.1.x 經典框架入門完整步驟,從下載到建立第一個資料庫驅動的應用程式。
wget https://yii.googlecode.com/files/yii-1.1.12.b600af.tar.gz
tar -xzf yii-1.1.12.b600af.tar.gz -C /var/www/html
mv /var/www/html/yii-1.1.12.b600af /var/www/html/yii
瀏覽 https://127.0.0.1/yii/requirements/index.php,確認核心項目:
extension_dir 絕對路徑extension=php_pdo_sqlite.dll
重啟 Apache 後可瀏覽:
https://127.0.0.1/yii/demos/helloworld/https://127.0.0.1/yii/demos/blog/cd /var/www/html/yii/framework
/var/php53/php yiic.php webapp /var/www/html/test1
瀏覽 https://127.0.0.1/test1/index.php 見到歡迎頁即成功。
CREATE TABLE `test1`.`test1_userinfo` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`uname` VARCHAR(45) NOT NULL,
`upass` VARCHAR(45) NOT NULL,
`count` INTEGER UNSIGNED,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;
編輯 test1/protected/config/main.php:
'db'=>array(
'connectionString' => 'mysql:host=127.0.0.1;dbname=test1',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'password',
'charset' => 'utf8',
'tablePrefix' => 'test1_',
),
之後即可在任何處使用 Yii::app()->db 存取資料庫。