2013年2月15日 星期五

Yii 安裝 Bootstrap

安裝方法:
http://www.cniska.net/yii-bootstrap/setup.html

Github 版的 Yii Bootstrap 可以從這邊取得:
https://github.com/joujiahe/yii-bootstrap

注意: 需將 webapp/protected/extensions/bootstrap/theme/* 下的檔案複製到
webapp/themes/bootstrap/ 

Yii 使用偽靜態網址

在 webapp 下新增一個 .htaccess 檔,並將以下內容複製貼上:
RewriteEngine on

# 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

修改 webapp/protected/config/main.php 設定檔來啟用 urlManager:
		// uncomment the following to enable URLs in path-format
		'urlManager'=>array(
			'urlFormat'=>'path',
			'showScriptName'=>false,
			'urlSuffix'=>'.html',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),
這樣就可以將 index.php 藏起來並偽裝成 .html 的網址了。

2013年2月7日 星期四

Yii 抽象資料庫欄位類型的支援



Yii Migration 支援多種抽象欄位類型,如下所示:
  • pk: an auto-incremental primary key type, will be converted into "int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY"
  • string: string type, will be converted into "varchar(255)"
  • text: a long string type, will be converted into "text"
  • integer: integer type, will be converted into "int(11)"
  • boolean: boolean type, will be converted into "tinyint(1)"
  • float: float number type, will be converted into "float"
  • decimal: decimal number type, will be converted into "decimal"
  • datetime: datetime type, will be converted into "datetime"
  • timestamp: timestamp type, will be converted into "timestamp"
  • time: time type, will be converted into "time"
  • date: date type, will be converted into "date"
  • binary: binary data type, will be converted into "blob"