All Projects → chenyingqiao → Phero

chenyingqiao / Phero

这个是一个独立的orm组件可以使用在任何系统中,提供灵活的orm操作,注解形式的数据库和类的映射。This is a database query tool library. swoole mysql pool.

Projects that are alternatives of or similar to Phero

Examples Orms
Sample uses of CockroachDB with popular ORMs
Stars: ✭ 65 (-35%)
Mutual labels:  sql, orm
Oxidizer
📦 A Rust ORM based on tokio-postgres and refinery
Stars: ✭ 100 (+0%)
Mutual labels:  sql, orm
Dbx
A neat codegen-based database wrapper written in Go
Stars: ✭ 68 (-32%)
Mutual labels:  sql, orm
Objectivesql
ObjectiveSQL is an ORM framework in Java based on ActiveRecord pattern, which encourages rapid development and clean, codes with the least and convention over configuration.
Stars: ✭ 1,109 (+1009%)
Mutual labels:  sql, orm
Sequelize
Sequelize module for Nest framework (node.js) 🍈
Stars: ✭ 88 (-12%)
Mutual labels:  sql, orm
Sqlite orm
❤️ SQLite ORM light header only library for modern C++
Stars: ✭ 1,121 (+1021%)
Mutual labels:  sql, orm
Fastsql
Database rapid development framework for Java(数据库快速开发框架).
Stars: ✭ 100 (+0%)
Mutual labels:  sql, orm
Express Knex Objection
A simple API system on a pg database, using knex and objection to simplify connection and management
Stars: ✭ 20 (-80%)
Mutual labels:  sql, orm
Nymph
Data objects for JavaScript and PHP.
Stars: ✭ 97 (-3%)
Mutual labels:  sql, orm
Evolutility Server Node
Model-driven REST or GraphQL backend for CRUD and more, written in Javascript, using Node.js, Express, and PostgreSQL.
Stars: ✭ 84 (-16%)
Mutual labels:  sql, orm
Reform
A better ORM for Go, based on non-empty interfaces and code generation.
Stars: ✭ 1,103 (+1003%)
Mutual labels:  sql, orm
Jplusone
Tool for automatic detection and asserting "N+1 SELECT problem" occurences in JPA based Spring Boot Java applications and finding origin of JPA issued SQL statements in general
Stars: ✭ 91 (-9%)
Mutual labels:  sql, orm
Fluent
Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
Stars: ✭ 1,071 (+971%)
Mutual labels:  sql, orm
Pqt
Postgres schema definition, sql/go, code generation package.
Stars: ✭ 65 (-35%)
Mutual labels:  sql, orm
Gorose
GoRose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides six major database drivers: mysql,sqlite3,postgres,oracle,mssql, Clickhouse.
Stars: ✭ 947 (+847%)
Mutual labels:  sql, orm
Ebean
Ebean ORM
Stars: ✭ 1,172 (+1072%)
Mutual labels:  sql, orm
Ktorm
A lightweight ORM framework for Kotlin with strong-typed SQL DSL and sequence APIs.
Stars: ✭ 843 (+743%)
Mutual labels:  sql, orm
Xhgui Branch
uprofiler UI,xhprof UI,tideways UI , PHP Non-intrusive performance monitoring platform.
Stars: ✭ 872 (+772%)
Mutual labels:  sql, composer
Marlow
golang generator for type-safe sql api constructs
Stars: ✭ 83 (-17%)
Mutual labels:  sql, orm
Sql
A delightful SQL ORM ☺️
Stars: ✭ 89 (-11%)
Mutual labels:  sql, orm

介绍

phero是一个数据库查询的orm类库,注解形式的model以及方便快速的数据库操作方法

这是一个兴趣使然的ORM(手动斜眼笑)

V1.0.3

支持下列特性:

文档位于doc 可以查看test中单元测试的例子

安装

  • composer
composer require lerko/p-hero
  • git clone
git clone https://github.com/chenyingqiao/Phero.git;

第一个ORM

创建一个Unit

<?php 
/**
 * @Table[name=Parent,alias=parent]  
 * # name表示真正的表名称,如果没有配置就是类名为表明
 * # alias为别名
 */
class Parents extends DbUnit
{
    use Truncate;
    /**
     * @Field[type=int] # 只有标示@Field的属性才会被作为查询列
     * @Primary #标示为主键
     * @var [type]
     */
    public $id;
    /**
     * @Field
     * @var [type]
     */
    public $name;
}

对应的表结构为

+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(45) | YES  |     | NULL    |                |
+-------+-------------+------+-----+---------+----------------+

进行一些基础的查询

单表

$parent=new Parent("name");# 你也可以这样获取Unit的实例  $parent=Parent::Inc();
$parent->whereEq("id",2)->select(Cache::time(10));//Cache::time(10)表示缓存10秒

select `mother`.`name` from `Mother` as `mother`;

子查询

$Parents=new Parents();
$Marry=new Marry();
//#是会自动替换成使用本实体为子查询的父实体
//或者使用Marry::FF("{字段名称}");也可以生成对应Unit的字段名String
$Marry->whereEq("pid","#.`id`");
$Parents->whereEq("id",1)
    ->whereOrExists($Marry)->select();
SELECT
    `parent`.`id`, `parent`.`name`
FROM
    `Parent` AS `parent`
WHERE
    `parent`.`id` = 1
        OR EXISTS(
            SELECT
                `Marry`.`id`, `Marry`.`pid`, `Marry`.`mid`
            FROM
                `Marry`
            WHERE
                `Marry`.`pid` = `parent`.`id`
        );
关键字 对应sql符号
where{and/or}Eq =
where{and/or}Neq <> (!=)
where{and/or}In in
where{and/or}Not_in not in
where{and/or}Between between
where{and/or}Like like
where{and/or}Not_like not like
where{and/or}Lt <
where{and/or}Lr <=
where{and/or}Gt >
where{and/or}Ge >=
where{and/or}Regexp regexp
where{and/or}Isnotnull is not null
where{and/or}Isnull is null
where{and/or}Exists exists
where{and/or}Not_exists not exists
where{Lt/Lr/Gt/Ge}{and/or}All all
where{Lt/Lr/Gt/Ge}{and/or}Any any

删除

$parent=new Parent();
$parent->whereEq("id",2)->delete();

更新

$parent=new Parent([
    "name"=>"this is change!"
]);
$parent->whereEq("id",2)->update();

插入

#id是自增主键没有进行赋值
$parent=new Parent([
    "name"=>"插入"
]);
#不用构造函数赋值你也可以这样直接赋值
$parent->name="这个是直接赋值";
$parent->insert();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].