This package is abandoned and no longer maintained. The author suggests using the doctrine/dbal package instead.

PHP class to perform SQL queries easily

1.9.0 2020-11-03 07:23 UTC

This package is auto-updated.

Last update: 2021-11-16 18:40:16 UTC


README

PHP class to perform SQL queries easily

Latest Stable Version License

Requirements

  • PHP >= 5.3
  • PHP extension mysqli

Installation

Install directly via Composer:

$ composer require phyrexia/sql

Basic Usage

<?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();