承接 rhlegacy/mysql-connector 相关项目开发

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

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

rhlegacy/mysql-connector

Composer 安装命令:

composer require rhlegacy/mysql-connector

包简介

This library assists with easily communicating with a mysql database.

README 文档

README

php-mysql-connector

A simple to use mysql connector for quickly connecting your php project with a mysql database

Installation

You can install this library using composer by adding it to your composer.json file

"require": {
    "mincdev/mysql-connector": "^1.*"
}

or running the following command:

composer require mincdev/mysql-connector

Usage

To use the connector, you need to include it in your file and intialise it with your database details.

use MySql\Connector;

$conn = new Connector([
    "host"      => "127.0.0.1",
    "user"      => "root",
    "passwd"    => "secret",
    "schema"    => "my_db",
]);

Once initialised you can use the connector in the following manner:

Insert a record

$conn->prepare("INSERT INTO table_name (column_1, column_2) VALUES (:column_1, :column_2)", [
    ":column_1" => "Hello World!", 
    ":column_2" => 1234
])->modify();

Row Count

$conn->prepare("SELECT * FROM table_name", null)->rowCount();

Fetch Single Column Value

$conn->prepare("SELECT column_name FROM table_name", null)->query();

Get last insert id

$conn->lastInsertId();

Select row(s)

Returns a single row or multiple rows

$conn->prepare("SELECT * FROM table_name", null)->select()

Quickly delete a record

Requires the primary key id to be passed and the table name

$conn->delete("table_name", 6);

Quick Insert

Inserts a record to the specified table using an array as the table structure.

$conn->quick_insert("table_name", ["column_1" => "Hello World!", "column_2" => 123]);

Quick Update

Updates a record in the specified table using an array as the table structure.

$conn->quick_update("table_name", 9, ["column_1" => "Hello World!", "column_2" => 123]);

Bulk Insert

Inserts multiple records to a specified table using an array as the table structure.

$conn->bulk_insert("table_name", [
    ["column_1" => "Hello World!", "column_2" => 1],
    ["column_1" => "Hello Galaxy!", "column_2" => 2]
]);

Multi Modify (Multiple Statements)

Runs multiple statements on the database one after the other. Each statement is separated by a semi-colon ";"

$conn->prepare("DELETE FROM table_name;INSERT INTO table_name (column_1, column_2) VALUES (:column_1, :column_2)", [
    null, // No key value pairs for the delete statement
    [":column_1" => "Hello World!", ":column_2" => 123] // Key value pairs for the second statement (insert)
])->m_modify();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固