zoukankan      html  css  js  c++  java
  • 0803THINKPHP基础:数据库操作

    链接数据库

    一、配置文件定义  TP5applicationdatabase.php

      // 数据库类型

      'type'            => 'mysql',

      // 服务器地址

      'hostname'        => '127.0.0.1',

      // 数据库名

      'database'        => 'ceshi',

      // 用户名

      'username'        => 'root',

      // 密码

      'password'        => '',

      // 端口

      'hostport'        => '',

    二、方法配置

      1、使用数组

      $db = Db::connect([

        // 数据库类型

        'type'            => 'mysql',

        // 服务器地址

        'hostname'        => '127.0.0.1',

        // 数据库名

        'database'        => 'ceshi',

        // 用户名

        'username'        => 'root',

        // 密码

        'password'        => '',

        // 端口

        'hostport'        => '',

      ])

      3、使用字符串的形式

      $db = Db::connect("mysqly://root:123@127.0.0.1:3306/ceshi#utf8");

      数据库类型://用户名:密码@数据库地址:数据库端口/数据库名#字符集

  • 相关阅读:
    1. DataBinding
    DataBinding 笔记
    做过的自定义 View
    自定义View
    拖拖看小游戏
    UIView
    UIButton
    故事板
    (译)Getting Started——1.3.4 Writing a Custom Class(编写自定义的类)
    (译)Getting Started——1.3.3 Working with Foundation(使用Foundation框架)
  • 原文地址:https://www.cnblogs.com/zhangbaozhong/p/9416488.html
Copyright © 2011-2022 走看看