MySQL in OpenSencillo – Connecting and create new table

We have four classes for SQL in three layers:

MySQL classes diagram

  • mysql – Main SQL class with minimal servicing database (manual SQL query and testing only)
  • mysqlEdit – Extension for class mysql (useful for generating simple SQL queries)
  • logMan – Extension for class mysqlEdit (useful for login and user management)
  • mysqlInterface – Extension for class mysqlEdit (best way for create and management custom tables)

mysqlInterface PHP OpenSencillo example:

//call class mysqlInterface
$mysql = new mysqlInterface($DBHost,$DBName,$DBUser,$DBPass);
//prepare table structure
$newTable = array('hostCtr'=>array(

//create shadow configuration and open connection to OpenSencillo database
//add new table
//collected all queries from the last execute and send queries to SQL server
echo "SQL changes saved!";

Output to SQL:
New table: hostCtr
Structure of new table:

  • id – int, auto_increment, primary_key
  • ip – varchar(15), unique_key
  • datetime – datetime

Now you can save your own data. Continue like this:

//continue yourcode.php
//assign data structure
$newInsert = array('hostCtr'=>array(
    'datetime'=>"'".date('Y-m-d H:i:s')."'")
//add structure and data to SQL generator
//execute generated queries

Now you save new id, new unique ip with date and time.