thinkphp学习小记

1.加载模板时报错:Class ‘Model‘ not found FILE: E:\wamp\www\thinkphp\Application\Home\Model\FormModel.class.php  LINE: 7
解决方法:namespace Home\Model; use Think\Model; 加上命名空间。并且必须放到代码的首行,不然会报错并且不起作用。
new Model()方法出错:$Model = new Model() 提示:Class ‘Home\Controller\Model‘ not found
错误位置:FILE: E:\wamp\www\kschao\wwwroot\Application\Home\Controller\IndexController.class.php  LINE: 21
getLastSql()出错:提示:Call to a member function getLastSql() on a non-object
代码如下:$student = new Model(‘student‘);$result=$student->select();echo $result->getLastSql();
改为$student = new Model(‘student‘);$result=$student->select();echo $student->getLastSql();就ok了。原因是只能对模型使用getLastSql()方法

 

2.路由
step1:打开路由 在项目配置中而不是在系统配置中
step2:设置路由规则 路由规则分为正则路由和规则路由。

3.php缓存?????

3.空模板和空操作

4.前置和后置操作
function _before_index()
function _after_index()

4.页面跳转和页面重定向
内置两个跳转方法error和success,分别用于错误跳转和成功跳转。会自动跳转到指定的地址,但是url地址不会发生变化
内置redirect方法实现页面的重定向,重定向后会改变当前的url地址。

5.自动验证和自动完成
自动验证:protected $_validate()=array() 自动完成:protected $_auto=array()

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。