以下框架都实现了两种查询方式
Query Builder + ORM
Eloquent ORM : https://laravel.com/docs/7.x/eloquent
代码示例
namespace App;
use Illuminate\Database\Eloquent\Model;
// 定义
class Flight extends Model
{
//
}
// 使用
DB::table('users')->where('votes', '=', 100)->get();
$flight = App\Flight::where('number', 'FR 900')->first();
文档 https://www.kancloud.cn/manual/thinkphp5/135176
ThinkPHP7.0之后单独拆开
ThinkORM: https://www.kancloud.cn/manual/think-orm/
namespace app\index\model;
use think\Model;
// 定义
class User extends Model
{
}
// 使用
Db::name('user')->where('id','>',10)->select();
// 或者
User::where('id','>',10)->select();
文档 https://github.com/sdispater/orator
# 定义
class User(Model):
pass
# 使用
db.table('users').where('age', '>', 25).get()
# 或者
users = User.where('votes', '>', 100).take(10).get()
Lucid models https://adonisjs.com/docs/4.1/lucid
'use strict'
const Model = use('Model')
const Database = use('Database')
// 定义
class User extends Model {
}
// 使用
Database
.table('users')
.where('username', 'john')
.first()
// 或者
const adults = await User
.query()
.where('age', '>', 18)
.fetch()
目前(2020.3)的一些参数比较
框架 | 语言 | 最新版本 | Github Star | Github |
---|---|---|---|---|
Laravel | PHP | 7.x | 58.1k | Github |
AdonisJs | Node.js | 5.0 | 7.9k | Github |
ThinkPHP | PHP | 5.0 | 2.8k | Github |
Orator | Python | 0.9.9 | 1.1k | Github |
除了ThinkPHP有完整的中文文档之外,其他框架都是英文的或翻译版