PHP code example of threeletters / supersql

1. Go to this page and download the library: Download threeletters/supersql 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/ */

    

threeletters / supersql example snippets


new SuperSQL($dsn,$user,$pass);

use SuperSQL\SuperSQL;

// MySql setup
$host = "localhost";
$db = "test";
$user = "root";
$pass = "1234";

$dsn = "mysql:host=$host;port=3306;dbname=$db;charset=utf8";
$SuperSQL = new SuperSQL($dsn,$user,$pass);

use SuperSQL\SQLHelper;

// MySql setup
$host = "localhost";
$db = "test";
$user = "root";
$pass = "1234";

$SuperSQL = SQLHelper::connect($host, $db, $user,$pass);

$result = $SuperSQL->select("test",[],[
    "condition" => 12345,
    "[||][&&]" => [
        "something" => "value",
        "anotherthing" => "val"
    ]
]); // SELECT * FROM `test` WHERE `condition` = 12345 OR (`something` = 'value' AND `anotherthing` = 'val')

if (!$result->error()) {
foreach ($result as $val) { // NOTE, $result is NOT an array
    echo $val;
}
} else {
echo json_encode($result->error());
}