怎么样配置phpMyAdmin在phpstorm中使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/iheyu/article/details/89766208
1.http://localhost/phpMyAdmin/—>数据库—>新建数据库(youhe)—>格式utf8_general_ci—>创建;
2.选择youhe数据库—>新建数据表;
3.D:\phpStudy\WWW\demo2\application\admin\controller\Login.php
内容没变
4.D:\phpStudy\WWW\demo2\application\admin\model\Login.php
<?php
namespace app\admin\model;
use think\Model;
class Login extends Model
{
    public function login($username,$password){
//        $admin= \think\Db::name('admin')->where('username','=',$username)->find();
        $user= \think\Db::name('user')->where('username','=',$username)->find();
//        if($admin){
        if($user){
//            if($admin['password']==md5($password)){
            if($user['password']==$password){
                \think\Session::set('id',$user['id']);
                \think\Session::set('username',$user['username']);
                return 1;
            }else{
                return 2;
            }

        }else{
            return 3;
        }
    }
}
//是没有修改的内容,下面是已修改的内容;
把$admin和括号里的字符串admin、都修改成创建数据库要是使用的表名;
D:\phpStudy\WWW\demo2\application\database.php
return [
    // 数据库类型
    'type'            => 'mysql',
    // 服务器地址
    'hostname'        => '127.0.0.1',
    // 数据库名
    'database'        => 'youhe', //你创建或导入的数据库名
    // 用户名
    'username'        => 'root',
    // 密码
    'password'        => '****',
    // 端口
    'hostport'        => '',
    // 连接dsn
    'dsn'             => '',
    // 数据库连接参数
    'params'          => [],
    // 数据库编码默认采用utf8
    'charset'         => 'utf8',
    // 数据库表前缀
    'prefix'          => 'yh_',  // 你创建或导入数据库表名的前缀
http://www.iheyu.com/demo2/public/index.php/admin/login
可以出现后台登录界面

猜你喜欢

转载自blog.csdn.net/iheyu/article/details/89766208