phyrexia / sql
1.9.0
2020-11-03 07:23 UTC
Requires
- php: >=5.3
- ext-mysqli: *
Suggests
- phyrexia/orm: PHP class for an easy to use ORM
README
PHP类,用于轻松执行SQL查询
要求
- PHP >= 5.3
- PHP扩展mysqli
安装
直接通过Composer安装
$ composer require phyrexia/sql
基本用法
<?php require 'vendor/autoload.php'; use Phyrexia\SQL\SimpleSQL; //First call: generate instance (next calls won't need parameters, Singleton <3) $SQL = SimpleSQL::getInstance(DATABASE, HOST, PORT, USER, PASS); //Do some SQL query $SQL->doQuery('SELECT * FROM table'); //Count returned rows $count = $SQL->numRows(); //Fetch results (associative array) $rows = $SQL->fetchAllResults(); //Do another SQL query $SQL->doQuery('SELECT * FROM table2 LIMIT 1'); //Fetch a single result $row = $SQL->fetchResult();