thinkphp数据库的问题
用thinkphp框架。new Model()的时候会出错。
Exception里的信息好像是
“Access denied for user ‘root’@’localhost’ (using password: NO)”
但是我已经在config.php里配置好信息了。
其中数据库名称为test,表为think_em。
- PHP code
<!---ecms 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也错。 <p>+本文来源gao!%daima.com搞$代*!码9网(</p><strong>搞gaodaima代码</strong> //... }catch (Exception $e){ dump($e); } }}?>
- PHP code
<!---ecms 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,);?>
——解决方案——————–
1:上面的错误意思是密码不对,检查一下密码和端口。
2:new Model(”);改成:$test=M(‘Em’);
——解决方案——————–
删除 Runtime 中的所有内容后重试