Home > Backend Development > PHP Tutorial > thinkphp数据库的有关问题

thinkphp数据库的有关问题

WBOY
Release: 2016-06-13 10:06:04
Original
847 people have browsed it

thinkphp数据库的问题
用thinkphp框架。new Model()的时候会出错。
Exception里的信息好像是

"Access denied for user 'root'@'localhost' (using password: NO)"

但是我已经在config.php里配置好信息了。
其中数据库名称为test,表为think_em。


PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpclass IndexAction extends Action{        public function index() {        try{            $Test = new Model('em');//这里出错,改成think_em也错。                //...        }catch (Exception $e){            dump($e);        }    }}?>
Copy after login


PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpreturn array(    //'配置项'=>'配置值'    'DB_TYPE'=>'mysql',    'DB_HOST'=>'localhost',    'DB_NAME'=>'test',    'DB_USER'=>'root',    'DB_PWD'=>'welcome',    'DB_PORT'=>'3306',    'DB_PREFIX'=>'think_',    'APP_DEBUG'=>true,);?>
Copy after login




------解决方案--------------------
1:上面的错误意思是密码不对,检查一下密码和端口。

2:new Model('');改成:$test=M('Em');
------解决方案--------------------
删除 Runtime 中的所有内容后重试
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template