承接 hoangm/query 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hoangm/query

Composer 安装命令:

composer require hoangm/query

包简介

README 文档

README

Người thực hiện: Ngô Minh Hòa

Installation

    composer require "hoangm/query @dev"

Configuration

  • Create a config.ini file in root folder with content
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=database_name
    DB_USERNAME=root
    DB_PASSWORD=

and customize it

Usage examples

  1. Use Query Builder

        <?php
            require 'vendor/autoload.php';
            use Hoangm\Query\DB;
            $user = DB::table('users')->get();
  2. Use Model Builder

    • Create a model class

          <?php
              namespace App\Models;
              use Hoangm\Query\Model;
      
              class User extends Model
              {
                  protected static $table = 'users'; // table name
                  protected static $primary_key = 'id'; // primary key
              }
      • Usage
          <?php
              require 'vendor/autoload.php';
              use App\Models\User;
              $user = User::all();

Methods

Query Builder

  • table($table_name)

    • Set table name
  • select($columns)

    • Select columns
    • Example: select('id, name') or select(['id', 'name'])
  • where($column, $operator, $value)

    • Where condition
    • Example: where('id', '=', 1) or where(['id' => 1])
  • orWhere($column, $operator, $value)

    • Or where condition
    • Example: orWhere('id', '=', 1) or orWhere(['id', '=', 1], ['name', '=', 'Hoang'])
  • orderBy($column, $order)

    • Order by
    • Example: orderBy('id', 'desc')
  • limit($limit)

    • Limit
    • Example: limit(10)
  • offset($offset)

    • Offset
    • Example: offset(10)
  • join($table, $first, $operator, $second)

    • Inner Join
    • Example: join('users', 'users.id', '=', 'posts.user_id')
  • leftJoin($table, $first, $operator, $second)

    • Left Join
    • Example: leftJoin('users', 'users.id', '=', 'posts.user_id')
  • having($column, $operator, $value)

    • Having
    • Example: having('id', '=', 1) or having(['id' => 1])
  • insert($data)

    • Insert data
    • Example: insert(['name' => 'Hoang', 'email' => 'hoangominh01@gmail.com'])
  • update($data)

    • Update data
    • Example: update(['name' => 'Hoang2'])->where('id', '=', 1)
  • delete()

    • Delete data
    • Example: delete()->where('id', '=', 1)
  • get()

    • Get data
    • Example: get()
  • count()

    • Count data
    • Example: count()
  • first()

    • Get first data
    • Example: first()

Model Builder

  • all()

    • Get all data
    • Example: all()
  • find($id)

    • Find data by id
    • Example: find(1)
  • create($data)

    • Create data
    • Example: create(['name' => 'Hoang', 'email' => 'hoangominh01@gmail.com'])

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-12-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固