wfdaj/foxql

SQL Query Builer

dev-master 2021-06-30 03:18 UTC

This package is not auto-updated.

Last update: 2024-10-03 16:46:20 UTC


README

介绍

MySQL PHP库,完全拷贝自 webrium/foxql

安装 Foxql

composer require wfdaj/foxql

添加连接配置

use wfdaj\foxql\DB;

DB::addConfig('main',[
  'driver'          => 'mysql',
  'db_host'         => 'localhost',
  'db_host_port'    => 3306,
  'db_name'         => 'test',
  'username'        => 'root',
  'password'        => 'root',
  'charset'         => 'utf8mb4',
  'result_stdClass' => true
]);

现在可以开始工作了:)

SELECT

$user = DB::table('users')->find($user_id);
MethodAlias
whereand
orWhereor
is
true
false

where

..->where('name','jan')->..

( where , and )

DB::table('uses')
->where('age','>',18)
->and('score','>',200)
->get();

( where , or )

DB::table('uses')
->where('age','>',18)
->or('score','>',200)
->get();

( is , true , false )

is 方法默认为true,可以将第二个参数设置为false

$list = DB::table('users')->is('confirm')->get();       //.. `confirm` = true
$list = DB::table('users')->is('confirm',false)->get(); //.. `confirm` = false


// 您可以使用 true 或 false 方法

DB::table('users')->true('confirm')->get();
DB::table('users')->false('confirm')->get();

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request