A easy way to control your SQL with a very minimal of work. SSQL stands for Simple structure query language. Which makes this your SQL and storage more easy to create/remove/update/filter your SQL data.
First you have to load up the lib, by writting this:
<?php
require_once('{basepath}/ssql.lib.php');
$ssql = new SSQL();
$ssql->style($darkmode=true); //loads stylesheet(place in head tag)
?>this is the most imporant thing in order for this to work, your credentals must be active, use:
$ssql->setCredential('{servername}', '{username}', '{password}'); //return booleanto close the connections:
$ssql->close();to make sure your database exists use:
$ssql->checkDB(string $dbname); // returns booleanTo remove the database use:
$ssql->dropDB(string $dbname); //returns booleanTo create a database use:
$ssql->makeDB(string $dbname); //return booleanto reset a database(remove and recreate the database) use:
$ssql->resetDB(string $dbname); //return booleanto select a database, use:
$ssql->selectDB(string $dbname);//return $this
//or
$db = $ssql->selectDB(string $dbname); //return $thisNote: you must have $ssql->selectDB(string $dbname) in a variable or use that to proceed on making the tables happen!, I used $db= for this example
# path to SQL file(.sql) and will automatically import all data to the data
$db->import(string $filepath);To create a table use:
$db->makeTable(string $tbname, array $items, array $types, array $values, array $options); //returns boolTo remove a table use:
$db->dropTable(string $tbname); //returns booleanTo check for an existing table use:
$db->checkTable(string $tbname); //returns booleanTo add more data use:
$db->addData(string $tbname, array $data, array $values); //return boolean
/*
to add multiple values do:
[[array1],[array2],[array3]]
*/To select an array of data use:
$db->selectData(string $tbname, array $sel, string $condition=''); //returns arrayTo delete an data use:
$db->dropData(string $tbname, string $condition=''); //returns booleanTo update a data use:
$db->updateData(string $tbname, string $replacement, string $condition=''); //returns booleanTo create/replace permissions use:
$ssql->givePerm(array $perm, string $tbname, array $username); //returns booleanTo remove permissions use:
$ssql->dropPerm(array $perm,string $tbname, array $username); //returns booleanTo create an account use:
$ssql->makeUser(string $username, string $psw='', bool $checkExists=true ,array $options=[]); //returns booleanTo remove an account use:
$ssql->dropUser(string $username); //returns booleanto load a view use:
echo $db->makeView(string $viewName, string $tbname, array $data, string $condition='', array $options=[]); //return string:tableto remove view use:
$db->dropView(string $viewName); //returns booleanGenerate Password, use:
$ssql->genPsw($salt=''); //returns string- Conditions:
lastname="fred",id=2,email="example@example.com",etc... They only acceptWHEREconditions - Options:
AUTO_INCREMENT,PRIMARY,KEY, etc... or any extended version of conditions:LIKE,IF,AND, etc...