• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

thinkphp数据库的有关问题

php 搞代码 4年前 (2022-01-23) 9次浏览 已收录 0个评论

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 中的所有内容后重试


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:thinkphp数据库的有关问题
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址