pfinal/database

PHP MySQL database wrapper, extends PDO and PDOStatement

v1.12.4 2020-05-11 08:08 UTC

README

数据库操作类

PHP交流 QQ 群:16455997

环境要求:PHP >= 5.3

使用 composer

composer require "pfinal/database"
<?php

  require __DIR__ . '/../vendor/autoload.php';

  $config = array(
      'dsn' => 'mysql:host=localhost;dbname=test',
      'username' => 'root',
      'password' => '',
      'charset' => 'utf8',
      'tablePrefix' => 'db_',
  );
  
  $db = new \PFinal\Database\Builder($config);
  
  $id = $db->table('user')->insertGetId(['username' => 'Jack', 'email' => 'jack@gmail.com']);
  
  echo $id;
  

更多用法请点击这里

如果你的项目未使用Composer,请使用下面的方式做类自动加载

<?php

    include "./database/src/ClassLoader.php";
    
    $loader = new \PFinal\Database\ClassLoader();
    $loader->register();