ActiveRecord言語はPHP、Python、Nodeを実現する.js

10154 ワード

次のフレームワークでは、2つのクエリー方式Query Builder+ORMを実現しています.
Laravel
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();

ThinkPHP
ドキュメント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();

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()

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()

まとめ
現在(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には完全な中国語ドキュメントがあるほか、その他のフレームワークは英語または翻訳版です.