PHP code example of phyrexia / sql

1. Go to this page and download the library: Download phyrexia/sql library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phyrexia / sql example snippets



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