ITeye博客

thinkphp

共 9 篇文章

TP在APP_DEBUG=false的情況下,CLI和WEBSITE會共用同一個~runtime.php導致出錯的問題解決辦法

TP若使用了 define('APP_DEBUG',false); 會生成./Runtime/~runtime.php 緩存文件,以後每次調用都會用這個文件來處理 但是若一個項目又使用了CLI,CLI生成的./Runtime/~runtime.php 文件跟website是同一個文件,而且cli生成的./Runtime/~runtime.php文件少了一些定義,例如__ROOT__ if(!IS_CLI) { // 当前文件名 if(!defined('_PHP_FILE_')) { if(IS_CGI) { //CGI/FASTCGI模式下 $_temp = explode('.php',…

2015-12-14 11:43 · php · thinkphp · PHP · thinkphp

TP3.2的try catch如何捕获异常

参考:http://www.oschina.net/question/723831_218382 public function t(){ try { throw new \Exception("haha"); }catch (Exception $e){ dump($e); } } 以上catch无法捕捉到,会出现ERROR的页面。因为catch (Exception $e){捕获的是当前module的Exception类,而不是\Exception,因此需要改成 public function t(){ try { E("errr"); }catch (\Exception $e){ d…

2015-10-29 17:16 · thinkphp · PHP · thinkphp

TP的module支持中文

為了讓URL支持中文,例如www.xxx.com/廣州/xx 需要在emptyAction中處理捕獲到的廣州/xxxx。但是TP默認的module名稱是不支持中文的。因此需要修改TP框架的PHP核心文件: App.class.php 修改後的代碼: /** * 执行应用程序 * @access public * @return void */ static public function exec() { if(!preg_match('/^[a-za-z](\w)*$/',MODULE_NAME) ){ // 安全检测 $module = false; }else{ //创建Action控…

2015-05-20 14:06 · php · thinkphp · PHP · thinkphp

TP升级到3.2.3的注意事项

从TP3.2.2升级到3.2.3有以下几点需要注意 1 TP3.2.3的DB FIELD默认小写,如果DB有大小写混合的设计,需要在config.php添加以下设置 'DB_PARAMS' => array(\PDO::ATTR_CASE => \PDO::CASE_NATURAL), 2 'URL_CASE_INSENSITIVE' =>true時,APP_DEBUG=true,若Action名或模板名帶有大小寫,會出現找不到模板的異常,因此'URL_CASE_INSENSITIVE' 一律設置為false(默認值) 3 APP_DEBUG設置在index.php,config.php不需…

2015-02-16 10:14 · php · thinkphp · thinkphp

TP3.1以上版本field的內容不要加空格,否则会被过滤

3.1以上版本支持field("a,b,c",true)的写法,这样查询出的field就会过滤掉a,b,c这三个字段。但是如果写成field("a, b, c", true)则只会过滤掉a则会把b,c显示出来。因为多了空格 错误写法: $this->field("id,issueID,landscapeCoverID, portraitCoverID,bookIndex, updateTime,updateUser,editTime", true) ->where("id=$bookID")->find(); 转换成的sql SELECT book , bookKicker , reader…

2015-01-20 10:11 · php · thinkphp · thinkphp

TP3.2的URL忽略大小写配置导致找不到模板

我在TP中开启了 'URL_CASE_INSENSITIVE' => true, //默认false 表示URL区分大小写 true则表示不区分大小写 结果导致页面找不到模板,原因就是因为这个配置忽略了大小写,TP去找对应的模板时是用全部小写,忽略了大小写。因此找不到有大小写的Action对应的模板。 在APP_DEBUG=true时是没问题的,在APP_DEBUG=false时才会出现找不到模板的问题。 要注意下。

2015-01-08 09:51 · php · thinkphp

TP getField不支持多表查询

$time = time() - 60 60 24; // 一天之前的臨時文件 $yesterday = date("Y-m-d H:i:s", $time); $fileIDs = M("dpp_tmp_page, file")->where("dpp_tmp_page.fileID=file.fileID and file.createDate < '" . $yesterday . "' and file.status=1")->getField("dpp_tmp_page.fileID", true); 期望查询结果:获取fileID数组。 实际查询结果:sql执行正确,但是查询结果…

2014-11-12 10:16 · php · thinkphp · PHP

TP3.2的import不能import Tp/library下的類

比如在\ThinkPHP\Library\Org\Util下的類 String.class.php 如果用 import("Org.Util.String"); $s = new \String(); 會報錯。如果這個String.class.php是放在分組下的ORG則是可以實例化的。而放在自動加載的類庫路徑中是不行的。 只能通過\Org\Util\String這樣的方式來調用。。 這種設計真是太不方便了。吐槽一下。

2014-08-01 14:32 · thinkphp

thinkphp不会识别unsigned int数据类型,会导致sql执行错误

数据库中是 unsigned int, 支持40多亿, 但用tp进行查询的时候, where方法会自动把大于2147483647的(有符号int最大值) 转化成 2147483647 print_r($condition); $Mode->where($condition)->find(); echo $Mode->getlastSql(); 结果: Array ( [sid] => 2147645095 [type] => icili ) SELECT * FROM al_qitadianying WHERE ( sid = 2147483647 ) AND ( type = 'icili…

2013-11-19 10:14 · thinkphp