1. Go to this page and download the library: Download tylersriver/php-simple-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/ */
impleSQL\SQL as SQL;
$sql = 'select * from test where field = ? and field2 = ?';
$params = ['fieldValue', 'field2Value']; // Params added in order of '?' placement in query
$result = SQL::query($sql, $params);
// This class will hold all operations for 1 DB table
use SimpleSQL\SQL as SQL;
class TestUser extends SimpleSQL\ORM
{
protected static $table = "testUser"; // Exact mysql table name
protected static $key = "id"; // the primary key field name
protected static $fields = "id, firstName, lastName, startDate, isActive"; // the fields you want returned fromt the table
public static function GetUsersForStuff()
{
// Additional functions can be added for custom operations
$sql = "SELECT * FROM testUser ... ";
return SQL::query($sql);
}
}
// Using the class
$results = TestUser::Get(123) // parameter is id of record
$newRecord = TestUser::Add(['firstName' => 'Tyler']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.