建立这样一个model。
…………………………………………
namespace Home\Model;
Class UserModel extends \Think\Model {
Protected $autoCheckFields = false;
}
设置autoCheckFields属性为false后,就会关闭字段信息的自动检测,因为ThinkPHP采用的是惰性数据库连接,只要你不进行数据库查询操作,是不会连接数据库的。
…………………………
然后 $a = D('User');
会报错
……………………………………………………………………
:(
无法加载数据库驱动: Think\Db\Driver\
错误位置
FILE: D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\Db.class.php LINE: 42
TRACE
#0 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\Db.class.php(42): E('???????????????...')
#1 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\Model.class.php(1423): Think\Db::getInstance('')
#2 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\Model.class.php(97): Think\Model->db(0, '', true)
#3 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Common\functions.php(596): Think\Model->__construct('User')
#4 D:\phpStudy\WWW\BookDataCenter\Application\Home\Controller\IndexController.class.php(30): D('User')
#5 [internal function]: Home\Controller\IndexController->index()
#6 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\App.class.php(164): ReflectionMethod->invoke(ob
#7 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\App.class.php(202): Think\App::exec()
#8 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\Library\Think\Think.class.php(120): Think\App::run()
#9 D:\phpStudy\WWW\BookDataCenter\ThinkPHP\ThinkPHP.php(97): Think\Think::start()
#10 D:\phpStudy\WWW\BookDataCenter\index.php(24): require('D:\phpStudy\WWW...')
#11 {main}
最佳答案