2017 © Pedro Peláez
 

library score

个人使用Dao层驱动

image

swirldawn/score

个人使用Dao层驱动

  • Wednesday, March 21, 2018
  • by swirldawn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SCore

  • 一个简单的db数据库类 仿照laravel的DB类使用方式实现
  • 但是很轻便或者说很潦草
  • 此类依赖medoo 所以直接复制了他的源文件 方便本地使用 >medoo帮助文档:https://medoo.in/api/get
  • 其他都是辅助的
  • Log 依赖monolog 不建议使用
"monolog/monolog": "1.23.0",

测试使用方式

compser 文件格式

{
    "repositories": [{
            "type": "git",
            "url": "https://github.com/swirldawn/score.git"
        },
        { "type": "composer", "url": "https://packagist.phpcomposer.com" },
        { "packagist": false }
    ],
    "require": {
        "swirldawn/score": "dev-master"
    }
}

入口文件测试

<?php
namespace Score;
//app的路径常量,必须
define('APPLICATION_PATH', dirname(__DIR__));

include_once("./vendor/autoload.php");
//config.php文件需要你按着config.php.example里面的格式在本地创建一个
require_once("config.php");
include_once("./vendor/swirldawn/score/src/functions.php");
//mysql 表前缀常量必须
define('TABLE_PREFIX', get_config("db.table_prefix"));

$list = \SCore\DB::table("users")->limit(1)->get();
dd($list);

php test.php, (*1)

常用操作

// 取回数据表的第一条数据
$user = DB::table('users')->where('name', 'John')->first();
DB::table('name')->first();
//获取所有
$all = DB::table('name')->get();
$all = DB::table('name')->where("age",">","20")->get();
//获取部分字段
$all = DB::table('name')->columns(['name','age'])->get();

//分页
$list = DB::table('name')->paginate();
// 插入
DB::table('users')->insert(
  ['email' => 'john@example.com', 'votes' => 0]
);

// 更新
DB::table('users')
          ->where('id', 1)
          ->update(['votes' => 1]);
// 删除
DB::table('users')->where('votes', '<', 100)->delete();

//查询sql
$list = \DB::select("select * from user");
//操作sql
$list = \DB::exec("delete  from user where id=1");
//聚合 只有三个
DB::table('users')->count();
DB::table('users')->max('age');
DB::table('users')->min('age');

The Versions

21/03 2018

dev-master

9999999-dev

个人使用Dao层驱动

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar swirldawn

21/03 2018

1.0

1.0.0.0

个人使用Dao层驱动

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar swirldawn