dr2gsistemas / korm
此包已被弃用且不再维护。未建议替代包。
伪库 ORM 工具库
dev-main
2022-04-24 02:56 UTC
Requires
- ext-pdo: *
Requires (Dev)
- pestphp/pest: ^1.21
This package is auto-updated.
Last update: 2024-08-03 20:45:22 UTC
README
伪库,用作 ORM 工具库。
💀 不要在生产环境中使用,仅供娱乐和实践!
💀 No utilice en producción, es solo por diversión y práctica
使用/用法
<?php use DR2GSistemas\korm\classes\Column; use DR2GSistemas\korm\classes\Entity; use DR2GSistemas\korm\classes\Index; /*Declare a class and extends with Entity class*/ /*Declarar la clase extendiendo con Entity*/ class Product extends Entity { //typed public fields //variables publicas tipadas #[Column(type:"integer", primaryKey:true, autoincrement:true)] public int $id; #[Column(type:"varchar(255)", nullable: false )] //declare as field varchar(255) not null #[Index(indexname:"idx_product_name",unique: false)] //declare as index with name idx_product_name and unique false public string $name; #[Column(type:"numeric(10,2)", nullable: true)] public float $price; public function __construct() { //optional: can define your tablename in the constructor //opcional: se puede definir el nombre de la tabla en el contructor $this->tablename = 'products'; } } /*init a new instance*/ /*iniciar la instancia*/ $product = new Product(); /*or create from json*/ /*o desde un json*/ $product = Product::fromJson(["name"=>"sugar", "id"=>1, "price"=>3.59]); /*populate from array...*/ /*poblar con un array...*/ $product->populate(["name"=>"sugar", "id"=>1, "price"=>3.59]); /*build a insert statement*/ /*construir la sentencia de inserción*/ $stmt = $product->insert(); /*build a update statement*/ /*construir la sentencia de actualización*/ $product->name = "sugar rainbow"; /* changed */ $product->price = "4.59"; $stmt = $product->update(); /*build delete statement*/ /*construir la sentencia de borrado*/ $stmt = $product->delete(); /*execute the stmt in a favorite conection */ /*ejecutar la sentencia en su conector favorito*/ GhostlyDatabaseInstanceManager::getInstace()->executeOrFail($stmt);
来自巴拉圭的Villeta,💖
从巴拉圭的Villeta,💖
历史
-
0.1.0:
- 开始旅程
-
0.1.1:
- 在 update() 和 insert() 上修复 detectPrimaryKeyFieldName 的bug
- 在 insert()、update() 和 delete() 上修复 detect tablename fieldname 的bug
- 添加 EntityTest.php 用于测试
-
0.1.2:
- 一些小修复
-
0.1.3
- 添加 selectAll() 和 selectOne()
-
0.1.4
- 添加 DDLBuilder 类
- 为实体添加 IDDL 接口
- public function _createDDL(): string;
- public function _dropDDL(): string;
- public function _createIndexesDDL(): array;
- public function _dropIndexesDDL(): array;
- public function _createForeignKeysDDL(): array;
- public function _dropForeignKeysDDL(): array;
- public function _resetAutoIncrement(int $value = 1): string;
待办事项
- 添加 selectAll() 和 selectOne() 函数
- 测试 selectAll() 和 selectOne() 函数
- 在构建语句时提高性能 🚤
- 关系 🔗
- 连接器 🔌
- 从类构建数据库模式 🔌
- 从数据库模式构建类 🏗️
- 编写更好的文档 📖
- 享受一位贡献者的 🍺 (可选)😄