gengbin/sqlbatis

这是一个帮助你更好地编写SQL的工具

v1.1 2022-11-27 09:41 UTC

This package is auto-updated.

Last update: 2024-09-28 11:56:13 UTC


README

这是一个PHP的SQL库。

这个项目做什么?

它可以帮助你更好地编写SQL。

为什么这个项目有用?

它可以帮助你避免封装SQL代码,让SQL开发变得极其简单。

安装

Composer

从命令行

composer require gengbin/sqlbatis

在你的 composer.json

{
  "require":{
    "gengbin/sqlbatis": "^1.0"
  }
}

基本用法

1. 建议你可以写封装。

<?php
require 'vendor/autoload.php';
use \Gengbin\Sqlbatis\Sqlbatis;
use Gengbin\Sqlbatis\entity\ConnectSource;
class Main_Database extends Sqlbatis
{
    function construct($connectData = '', $userName = '', $userPassword = ''): ConnectSource
    {
        $a = new ConnectSource();
        $a->setConnectData('mysql:host=localhost;dbname=mysql');
        $a->setUserName('root');
        $a->setUserPassword('123456');
        return $a;
    }
}

2. 你可以创建这个对象

<?php
$m = new Main_Database();
$result = $m->query('SELECT * FROM mm;');
$result = $m->exec('INSERT INTO v(a) VALUES("123123123")');

如何开始?

你可以扩展Sqlbathis并重写构造函数和返回SQL连接信息为数组。然后你可以调用查询、执行、资源。 了解更多如何使用

如果需要更多帮助,我该去哪里?

如果你遇到问题,你可以提交问题,我们可以帮助你并感到高兴。