GithubHelp home page GithubHelp logo

zds-s / max-database Goto Github PK

View Code? Open in Web Editor NEW

This project forked from next-laboratory/database

0.0 0.0 0.0 99 KB

The database component of MaxPHP !

Home Page: https://www.chengyao.xyz

License: Apache License 2.0

PHP 100.00%

max-database's Introduction


Max

轻量 • 简单 • 快速

Max框架数据库组件

安装

该扩展依赖于MaxPHP,Max-Framework ,所以需要先安装MaxPHP

composer create-project max/max

安装

composer require max/database

使用

注册服务提供者

/config/http.php 或者/config/console.php中的provider下注册服务提供者类\Max\DatabaseService::class

配置文件

安装完成后框架会自动将配置文件database.php移动到根包的config目录下,如果创建失败,可以手动创建。

文件内容如下:

<?php

return [

    //默认数据库配置
    'default'  => env('database.default', 'mysql'),

    // mysql, pgsql, oci
    'mysql' => [
        //可以使用dsn来配置更多参数,会优先使用该参数
        'dsn'     => '',
        //主机地址
        'host'    => env('database.host', 'localhost'),
        //数据库用户名
        'user'    => env('database.user', 'user'),
        //数据库密码
        'pass'    => env('database.pass', 'pass'),
        //数据库名
        'dbname'  => env('database.dbname', 'dbname'),
        //端口
        'port'    => env('database.port', 3306),
        //额外设置
        'options' => env('database.options', [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]),
        //编码
        'charset' => env('database . charset', 'utf8mb4'),
        //数据表前缀
        'prefix'  => '',
        //主
        'master'  => [],
        //从
        'slave'   => []
    ],

];

方法

安装完成后就可以使用\Max\Facade\DB::name($table);等的方式来使用Database扩展,或者使用助手函数db($tableName)

官网:https://www.chengyao.xyz

max-database's People

Contributors

bbuugg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.