thinkphp数据库的问题
用thinkphp框架。new Model()的时候会出错。
Exception里的信息好像是
"Access denied for user 'root'@'localhost' (using password: NO)"
但是我已经在config.php里配置好信息了。
其中数据库名称为test,表为think_em。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
class IndexAction extends Action
{
public function index() {
try{
$Test = new Model('em');//这里出错,改成think_em也错。
//...
}catch (Exception $e){
dump($e);
}
}
}
?>
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
<?php
return 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,
);
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号