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 boolean
to close the connections:
$ssql->close();
to make sure your database exists use:
$ssql->checkDB(string $dbname); // returns boolean
To remove the database use:
$ssql->dropDB(string $dbname); //returns boolean
To create a database use:
$ssql->makeDB(string $dbname); //return boolean
to reset a database(remove and recreate the database) use:
$ssql->resetDB(string $dbname); //return boolean
to select a database, use:
$ssql->selectDB(string $dbname);//return $this
//or
$db = $ssql->selectDB(string $dbname); //return $this
Note: 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 bool
To remove a table use:
$db->dropTable(string $tbname); //returns boolean
To check for an existing table use:
$db->checkTable(string $tbname); //returns boolean
To 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 array
To delete an data use:
$db->dropData(string $tbname, string $condition=''); //returns boolean
To update a data use:
$db->updateData(string $tbname, string $replacement, string $condition=''); //returns boolean
To create/replace permissions use:
$ssql->givePerm(array $perm, string $tbname, array $username); //returns boolean
To remove permissions use:
$ssql->dropPerm(array $perm,string $tbname, array $username); //returns boolean
To create an account use:
$ssql->makeUser(string $username, string $psw='', bool $checkExists=true ,array $options=[]); //returns boolean
To remove an account use:
$ssql->dropUser(string $username); //returns boolean
to load a view use:
echo $db->makeView(string $viewName, string $tbname, array $data, string $condition='', array $options=[]); //return string:table
to remove view use:
$db->dropView(string $viewName); //returns boolean
Generate Password, use:
$ssql->genPsw($salt=''); //returns string
- Conditions:
lastname="fred"
,id=2
,email="example@example.com"
,etc... They only acceptWHERE
conditions - Options:
AUTO_INCREMENT
,PRIMARY
,KEY
, etc... or any extended version of conditions:LIKE
,IF
,AND
, etc...