yaophp / orm
一个独立于ThinkPHP 5.1.0RC1的ORM库
v5.1.0-RC1
2017-10-06 15:20 UTC
Requires
- php: >=5.6.0
This package is not auto-updated.
Last update: 2024-09-26 05:41:24 UTC
README
一个独立于ThinkPHP的ORM库
更新到5.1.0RC1
安装
git clone then composer install
或者
composer require yaophp/orm
使用方法
Demo.php
<?php require "vendor/autoload.php"; use yaophp\Orm; use think\Db; use think\Model; //your database config, more info in orm/src/config.php Orm::config([ 'username' => 'yourusername', 'password' => 'yourpassword', 'database' => 'yourdatabase' ]); //example 1: var_dump(Db::query('select * from article where id = :id', ['id' => 1])); //example 2: // from 5.1.0 RC1 where expression not support array type // var_dump(Db::name('article')->where(['id' => 1])->find()); // wrong var_dump(Db::name('article')->where('id', '=', 1)->find()); // right //example 3: //do not use the way "\think\Loader::model()" to get an instance of Model class Article extends Model { public function getId($id) { return $this->where('id', '=', 1)->find(); } } $article = new Article(); var_dump($article->getId(1));
链接
ThinkPHP (https://www.kancloud.cn/manual/thinkphp5_1/353997)