2013年10月17日 星期四

yii framework - shell指令時出現Error: index.php does not exist or is not an entry script file.

你會在你的專案底下的protected資料夾發現有個yiic.bat, 但是如果你在windows的命令提示字元輸入

>cd c:\xampp\htdocs\你的專案名稱\protected

接著輸入

>yiic shell

就會出現這句錯誤

>Error: index.php does not exist or is not an entry script file.

解決方法是要輸入

>yiic shell ../index.php

2013年10月15日 星期二

yii framework - 建立一個部落格要建立CRUD時候出錯了?

我想學 官網的部落格範例 一樣嘗試用yii建立一個blog, 但是在建立完model後, 要用
Crud Generator卻出現下面的error:

CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 near ".": syntax error. The SQL statement executed was: PRAGMA table_info('tbl_comment'.'tbl_post')

config資料夾裡的main.php的db設定是這樣

'db'=>array(
'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/blog.db',
'tablePrefix'=>'tbl_', //<- 加上這句告訴db我們資料表的前綴字是什麼

),

跟大陸的教學一樣但是還是不行, 為什麼會這樣呢?


2013年10月10日 星期四

yii framework - No input file specified 解決方法(正解)

1. 將server根目錄的php5.ini (沒有就建立一個)裡加上這句

cgi.fix_pathinfo = 1


2. 修改protected資料夾下的.htaccess, 把內容改成下面這樣 (不要傻傻複製上下的米號ㄟ)

*******************************************

Options +FollowSymLinks
IndexIgnore */*
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

*******************************************

怎麼學習PHP yii framework ?

我也是網路各種爬文、找資料 (我的習慣是先理解再實作)

找到幾個很棒的網站分享給大家:



http://www.yiiframework.com/doc/api/1.1/  (官網, 查Class-類、Properties-屬性、Methods-方法很好用)

http://www.yiichina.com/api/ (不要打我~ 就是有簡體版的沒錯! 但是上面是1.0版, 目前官方已經出到1.1版了!所以我有時候會中英對照看)

http://www.yiichina.com/topic/4786/ (裡面說這主要是透過開發Windows應用C++、C#工程師的角度幫助Windows 桌面應用或ASP.Net工程師較快的掌握PHP Yii Framework應用程序框架。)

http://www.yiiframework.com/doc/guide/1.1/zh_cn/index (官方的簡體指南, 試著跟著一步一步走還不錯, 至少能有個基本概念)