RJ博客

个人博客 TP框架迁移

本文目录


ThinkPHP3.2的升级知道可以看官方文档:

http://www.kancloud.cn/manual/thinkphp/1889


下面说说一些比较容易犯错的地方:

一、ThinkPHP3.2里面用F方法储存的数据都被序列化了。假设你用F方法把数据储存到配置文件,储存后的数据都是序列化之后的,这样你就不能像3.1那样用C方法读取配置文件的数据了。我们可以自己定义一个储存数据的方法解决之。在/Application/Common/Common创建function.PHP,然后添加以下代码:

<?php 
/**
 * [writeArr 写入配置文件方法]
 * @param  [type] $arr      [要写入的数据]
 * @param  [type] $filename [文件路径]
 * @return [type]           [description]
 */
function writeArr($arr, $filename) {
 	return file_put_contents($filename, "<?php\r\nreturn " . var_export($arr, true) . ";");
}

然后可以用这个writeArr方法来写入配置
调用方法:

// 写入配置文件
public function setConfig(){
	$file = CONF_PATH.'/setConfig.php';
	if(writeArr($_POST,$file)){
		$this->success('修改成功');
	}else{
		$this->error('修改失败');
	}
}

view sourceprint?


二、ThinkPHP3.2加载外部标签库出现“实例化一个不存在的类”错误

例如:

'APP_AUTOLOAD_PATH' => '@.TagLib',
'TAGLIB_BUILD_IN' => 'Cx,Hd',


改成,并放在对应模块的config.php里面,不要放在公共配置的config.php里面

'TAGLIB_BUILD_IN' => 'Cx,Home\TagLib\TagLibHd',
'TAGLIB_PRE_LOAD' => 'Home\TagLib\TagLibHd',


三、ThinkPHP3.2下import导入自定义类的问题

首先检查下命名空间有没有出错,然后还要做以下改动:

在import('Class.Image',APP_PATH)之后,实例化时,应该这样:

$Image = new \Image();

而不是

$Image = new Image();

因为这样的话会直接作为一个当前命名空间下的类使用,所以会报找不到类的错。


四、自定义标签库错误,parseXmlAttr()错误

3.2版本已经作废了该方法,所以要获取属性值,直接就可以通过$attr(属性数组) 变量来获得,

也就是释掉以下即可正常加载标签:

//$attr = $this->parseXmlAttr($attr);
//$attr($attr);


五、3.2版本M方法调用失败(3.1版本正常调用)

这个时候可以试下把MySQL的连接地址重 localhost 改成 127.0.0.1 即可正常调用M方法。

localhost will cause the MySQL client to try a UNIX socket in a standard directory. If that doesn't exist or is somewhere else, you won't be able to connect. 127.0.0.1 always uses a TCP connection.    


参考网址:

http://iwww.me/258.html

http://www.thinkphp.cn/topic/23917.html

http://stackoverflow.com

http://blog.liunianer.com/post-25.html

http://www.thinkphp.cn/topic/13186.html



相关推荐

发表评论

  • 欢迎评论

  • I'm happy to welcome you! Mass placement of ads on the online for growth of behavioural factors. website: xn----ftbeand5abdikisgee.xn--p1ai/home/ Behavioural factors are certain actions of visitors on the website, such as: logging in to the online resource, viewing pages, time spent on the web page, “clicks” on links, repeated returns to the internet resource. Unique Trading Offer: Mass placement of your ads on the Internet in order to attract potential customers. Growth of behavioural factors occurs by the large-scale placement of your ads without specifying the address of your online resource, but with the indication of other identifying features according to which you currently become first in the search engine results. These features can include a phone, a unique name of the company or website, an identifier (a number, a product code, services, promotions), a physical address of the firm and etc. MAIN AIM: The widespread attraction of potential custome

  • Dear sir! We offer sending newsletters of Your commercial offers via contact forms to the sites of firms via all countries of the world. Your commercial offer is sent to email of institution 100 percent will get to the inbox! 2000 bases: Price List =» xn----7sbb1bbndheurc1a.xn--p1ai/prajs-list/ Test: 20000 messages on foreign zones to your E-mail - twenty $. We need from You only email address, title and text of the letter. In our price there are more 800 databases for all domains of the world. Common databases: All Europe 44 countries 60726150 of sites - 1100$ All European Union 28 countries 56752547 of sites- 1000$ All Asia 48 countries 14662004 of domains - 300$ All Africa 50 countries 1594390 of domains - 200$ All North and Central America in 35 countries 7441637 of domains - 300$ All South America 14 countries 5826884 of sites - 200$ New sites from around the world registered 24-48 hours ago. (A cycle of 15 mailings during the month)

  • Hello from FbCourses.net Want to pay $0.01 a click? We got you covered. A great team of Global Digital Marketing experts have compiled this list of 13 Best Free Facebook Advertising Training, Classes and Courses to help you learn and excel at Facebook Ads & Marketing. Thousands of professionals have already benefited from this list on Facebook Training. Regards, Buster