Monthly Archives: May 2015

How to create an info file to the module?

There is $inc object that allows you to store information about modules. Module information system can move as follows.

Code in fw_modules/mymodule/info_mymodule.php

//-------your module group name------------//
//-------group information-----------------//
$inc->lib['group_'.$modname]['author']='Bc. Peter Horváth';
$inc->lib['group_'.$modname]['your_own_key']='my own info';
//-------your module group function--------//
$inc->lib['function'][]='test function';
$inc->lib['function'][]='smile function';
$inc->lib['function'][]='good function';

This saves the information about the module to RAM during execution of the script.
Information will be publicly available throughout the system.


Creating basic module

PHP code needs to be divided into multiple parts? Use OpenSencillo modules. You can then create logical units separate from the source code yourcode.php.

Obrazovka z 2015-01-28 19:41:35

  1. Open folder fw_modules.
  2. Create folders that will have the name of your module (for example: mymodule). At least one file in the folder must contain the name.
  3. Open folder mymodule and create info_mymodule.php, install_mymodule.php and main_mymodule.php. If you not use prefix, lib_identificator.php bootup module as basic code without installer.
  4. Add to info_mymodule.php simple information about module.
  5. Enter code to install_mymodule.php to install the module database tables, and other code needed for installation.
  6. Use main_mymodule.php to insert any code that need to be separated. Code shall be made for the introduction OpenSencillo.

Question: When OpenSencillo connect the module?
Ask: Before loading yourcode.php.

Question: Can I move code from yourcode.php into modules?
Ask: Yes, of course.


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.