ActiveRecord语言实现PHP、Python、Node.js
【摘要】 以下框架都实现了两种查询方式 Query Builder + ORM
Laravel
Eloquent ORM : https://laravel.com/docs/7.x/eloquent
代码示例
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
// 定义
class Fl...
以下框架都实现了两种查询方式
Query Builder + ORM
Laravel
Eloquent ORM : https://laravel.com/docs/7.x/eloquent
代码示例
<?php
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();
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
ThinkPHP
文档 https://www.kancloud.cn/manual/thinkphp5/135176
ThinkPHP7.0之后单独拆开
ThinkORM: https://www.kancloud.cn/manual/think-orm/
<?php
namespace app\index\model;
use think\Model;
// 定义
class User extends Model
{
}
// 使用
Db::name('user')->where('id','>',10)->select();
// 或者
User::where('id','>',10)->select();
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
Orator ORM
文档 https://github.com/sdispater/orator
# 定义
class User(Model): pass
# 使用
db.table('users').where('age', '>', 25).get()
# 或者
users = User.where('votes', '>', 100).take(10).get()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
AdonisJs
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()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
总结
目前(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有完整的中文文档之外,其他框架都是英文的或翻译版
文章来源: pengshiyu.blog.csdn.net,作者:彭世瑜,版权归原作者所有,如需转载,请联系作者。
原文链接:pengshiyu.blog.csdn.net/article/details/104882837
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)