hisoka / orm
orm php mysql
Requires
- php: >=7.4
- hisoka/env: dev-main
README
require 'vendor/autoload.php';
// require ORM
use Hisoka\Orm\DB;
// 实例化
$DB = new DB();
========================================
删除
========================================
$query = $DB->table('Utilisateurs') ->delete() ->where(["Identifiant" => 'login']) ->execute(); ->status();
========================================
选择所有
========================================
$query = $DB->table('Utilisateurs') ->select([]) ->where(["Identifiant" => 'login']) ->limit( 1 ) ->execute(); ->fetchAssociative();
========================================
通过选择
========================================
$query = $DB->table('Utilisateurs') ->select(["id", "nom" , ...]) ->execute(); ->fetchObject();
========================================
更新
========================================
$query = $DB->table('Utilisateurs') ->update() ->where(["Identifiant" => 'login']) ->execute(); ->status();
========================================
插入
========================================
$query = $DB->table('Utilisateurs') ->insert(["nom" => 'alexis']) ->execute(); ->status();
========================================
连接
========================================
joinWith( string $tableA , string $jointureA, string $tableB, string $jointureB, string $type = "" ) @ tableA => 要连接的 tableA @ jointureA => table A 中的连接 @ tableB => 要连接的 tableB @ jointureB => table B 中的连接 @ type => 可以为 INNER , LEFT , RIGHT ... 默认为简单的 JOIN
$Interfaces_acheves = $DB ->table('Interfaces') ->select(["Interfaces.Progression" , "Projets.IDProjets"]) ->where(
array( [ "key" => "Projets.IDProjets", "value" => 0, "operator" => "=" ], [ "key" => "Interfaces.Progression", "value" => 4, "operator" => ">" ], ) ) ->joinWith("Projets", "IDProjets" ,"Interfaces", "IDInterfaces") ->generateSQL(); // ->execute()->fetchAssociative();
========================================
附加功能
========================================
查看 PDOException 错误
$DB->debug();
查看 SQL 请求 PDOException
$DB->generateSQL();
查看请求状态
$DB->status();