quickhelper/quickorm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

quickhelper/quickorm

最新稳定版本:v2.0.0

Composer 安装命令:

composer require quickhelper/quickorm

包简介

ORM to manipulate databases through code without needing to write SQL queries.

README 文档

README

This repository contains a project that leverages ORM (Object-Relational Mapping) technology to manage and interact with databases in a convenient and efficient manner. The project demonstrates how to use ORM to manipulate databases through code without needing to write SQL queries directly.

Features

  • Simple API: Easily manipulate databases using objects and classes.
  • Full CRUD Support: Insert, read, update, and delete data effortlessly.
  • Dynamic Queries: Build SQL queries dynamically with QueryBuilder.
  • Relationship Management: Handle relationships between tables, including one-to-one, one-to-many, and many-to-many.
  • Database Compatibility: Works with most relational databases supported by PDO.

Installation

To install quickhelper/quickorm via Composer, run the following command in your project directory:

composer require quickhelper/quickorm

Basic Usage

Setting up a Database Connection

Configure the database connection settings in your configuration in config/database.php ;

Creating a Model

Create a model that represents a table in your database:

use QuickORM\Model;

class User extends Model
{
    protected $table = 'users';
}

CRUD Operations

  • Insert a New Record:
$user = new User();
$user->name = 'John Doe';
$user->email = 'john@example.com';
$user->save();
  • Read a Record:
$user = User::find(1);
echo $user->name;
  • Update a Record:
$user = User::find(1);
$user->name = 'Jane Doe';
$user->save();
  • Delete a Record:
$user = User::find(1);
$user->delete();

Custom Queries

Use QueryBuilder to create custom SQL queries:

use QuickORM\QueryBuilder;

$results = QueryBuilder::table('users')
    ->where('age', '>', 30)
    ->get();

Relationship Management

Define relationships between models:

class Post extends Model
{
    protected $table = 'posts';

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

class User extends Model
{
    protected $table = 'users';

    public function posts()
    {
        return $this->hasMany(Post::class);
    }
}

Contents

  • Introduction to ORM
  • Practical Examples
    • Creating objects and storing them in the database
    • Retrieving data from the database
    • Updating existing data
    • Deleting data
  • Best Practices

Project Advantages

  • Provides a convenient way to interact with databases.
  • Facilitates the process of managing software data.
  • Reduces errors caused by manual SQL queries.
  • Improves the efficiency and performance of applications.

How to Use

  1. Clone the Repository:

    git clone https://github.com/yossef-ashraf/QuickORM.git
  2. Environment Setup: Prepare your programming environment and install all required dependencies.

  3. Running Examples: Execute the examples included in the project to understand how to use the ORM.

Contribution

We welcome contributions to enhance this project. If you would like to participate, please:

  • Open an Issue for any questions or feedback.
  • Submit a Pull Request with your improvements.

License

This project is licensed under the MIT License.

Best regards,
Yossef Ashraf

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-04