ratingthomas/sqlmanager
最新稳定版本:2.0.1
Composer 安装命令:
composer require ratingthomas/sqlmanager
包简介
A small script that lets you easily interact with your mysql database
README 文档
README
SQLManager is a small script that lets you easily interact with your mysql database.
Features
- Easy to use
- Secure (SQL Injection prevention)
- Simple and fast
Installation
- Download the latest release with composer or from the releases page.
composer require ratingthomas/sqlmanager
- Put the script somewhere in your project.
- Add the following code:
<?php include 'path/to/SQLManager.php'; use Ratingthomas\SQLManager\SQL; $sql = new SQL\SQL(); ?>
How to use
Here i will explain how you can use the script.
Connect to Database
$sql->connect("db_name", "db_username", "db_password", "db_name");
| Parrameter | Details | Example |
|---|---|---|
| db_host | The database host. | localhost |
| db_username | Username | root |
| db_password | Password | admin |
| db_name | The name of the database | test |
Get data from the dabatase
Example 1
$result = $sql->query("SELECT * FROM users WHERE userid = ? AND user_type = ?", ['1', 'superadmin'], true); print_r($result);
Example 2
$result = $sql->query("SELECT * FROM users", []); print_r($result);
| Parrameter | Details | Example | Type | Required | Can be empty |
|---|---|---|---|---|---|
| query | The sql query | SELECT * FROM test; |
String | true | False |
| options | If you have a where statement | [$param1, $param2] |
Array | true | true |
| array_push | Make the array Multidimensional | true |
boolean | false | true |
| no_result | Set this to true if the sql query has no return falue | true |
boolean | false | true |
Get the connection info.
$sql->displayconnection()
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: AGPL-3.0-or-later
- 更新时间: 2023-09-01