承接 murage/sqlddl 相关项目开发

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

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

murage/sqlddl

Composer 安装命令:

composer require murage/sqlddl

包简介

Simple SQL Query builder. Worry less about the database connections and queries..

README 文档

README

Latest Stable Version Total Downloads License Coverage Status

Installation

First ensure the PHP version is greater or equal to 7

To include the library in an existing project using composer

composer require murage/sqlddl

or in composer.json add as dependency

"murage/sqlddl" : "^2.1.0"

This library is dependent on PHP dotenv and requires .env file at root of the project (env file does not have file name only extension .env; an example is provided). To get started include the following ENV variables to be able to get started (change as per your database connection)

DB_CONNECTION=mysql
DB_HOST=127.0.0.1 
DB_PORT=3306
DB_NAME=mydatabase
DB_USERNAME=secret
DB_PASSWORD=secret

where
DB_NAME=your database name

DB_USERNAME=your database username

DB_PASSWORD=your database password

Usages

The library utilizes nesting of functions, and does not require instantiating the Builder class. Start each query using :-

Builder::table( "provide the table name here")

Every query returns a json encoded response in format

{ "status": "either error or success",
  "response : "the response from the server",
  "code":"response code"
}

The code depends on the query being executed but on successful query, a code of 200 is returned. Where data is being fetched from the database, an array of records is returned in the response body e.g. :

{"status":success;
"response":
   [
    {"id":5, "colum1":"valueX"},
    {"id":6, "colum1":"valueK"}
    ],
 "code":200
}

Other response codes are here. All queries that normally do not fetch any value from the database on successful execution will return

{"status":success;
"response": "success",
 "code":200
}

To perform a basic select from table test

Builder::table('test')
    ->get();

or to just select everything in the table

Builder::table('test')
      ->all();

To select only fifty records

 Builder::table('test')
        ->get(50);

To select only 3 columns

    Builder::table('test)
        ->select('column1','column2','column3')
        ->get()

To select column1 but alias as name

Builder::table('test)
            ->select('column1 as name','column2','column3')
            ->get()

To select using where condition

  • where column1 equals numbers
Builder::table ('test')
    ->where('column1','=','numbers')
    ->get()
  • or this can be simplified as

    Builder::table ('test') ->where('column1','numbers') ->get()

allowed conditions include for where clause include

< , > , <> , != , <= , >= , =, IS, IS NOT, <=> 

To perform an insert

Builder::table('test)
        ->insert('data1','data2','data3')
        ->into('column1','column2','column3')

To truncate table test

Builder::table('test')
->truncate();

To drop table test

Builder::table('test')
->drop();
An up-to date documentation is cooking 🍴

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固