sqlay_php(3)SqLay Suitesqlay_php(3)

NAME

sqlay_php - small database oriented framework for use with PHP.

SYNOPSIS

sqlay_php is a small (currently not allowing to build complex forms or reports) PHP framework allowing to easily build database oriented pages (data sheets and data forms), simply by setting some variables in a PHP page and calling a function.

Besides from this it may also be used to build a (very) basic portal regardless of the use of any database.

FEATURES

The web pages generated by sqlay_php functions use minimalistic HTML features which should make them viewable by any browser compliant with HTML 3.2. In rare cases, HTML 4.0 features (such as span) may be used with only cosmetic consequences if viewed by an older browser.

Nevertheless, frames and framesets (but no pop-ups) are used with the consequence that ultra-light browsers such as those found in mobile phones are currently not in state to view those pages, or at least a full site (forms and sheets themselves may be viewed, but probably not menus).

Client side scripting language (such as Javascript) is currently not used, but may be in the future in a redundant fashion in order to speed up some operations. This means that the various functionalities (such as enforcement of checks on form completion) would be implemented both client- AND server-side and that the site should stay fully functional if scripting is disabled in the browser.

Cookies and sessions are currently not used either, maybe in the future but then, only as option that must be explicitly enabled in config. Again, this slows down operations and thus requires a powerfull server but ensures that ***any*** browser has access to the pages, without any need for cryptic URL's.

The internal structure is designed to be modulable but is not written in object oriented PHP. Maybe one day, either it will go back (previous attempts had been made in the past in this direction) to object oriented either internally with procedural bindings or the opposite way, but there is no immediate plan to do so.

INVOCATION

Before using any sqlay_php function in your PHP pages, you should first make sure that the directory above (NOT the directory itself) the SqLay library files is in the PHP include path, then you could make sure that a file called sqlay_config.php is found by your page.

Those two operations can be done in various ways, either in your page by hardcoding the sqlay_config.php path in the require directive in your page AND using an ini_set or ini_alter directive with the include_path parameter for the directory above SqLay libraries, or by putting both paths in the host's php.ini (generally requires root privilege), or by setting a php_value of type include_path with both paths either in an .htaccess file or in a vhost or even the main httpd.conf file, or any combination of those methods.

Then, you should fill some site wide global variables in the sqlay_config file. See sqlay_config (5) for details on those variables.

Then, you may begin writing pages using sqlay_php functions. In order to do that, you need to include the sqlay library page, by using a require directive and referencing it by prepending it's name by the 'sqlay/' prefix, then you should set some global variables inside the page (or in another file included from the page, as you like) and finally, call a function.

Most sqlay_php objects use GET and / or POST parameters to define their state following the way they are called. If you wish to use those objects in your pages, you should understand that some GET / POST parameter names have special meaning for them. Those are described in the next section.

OPTIONS

Here are the GET / POST parameters (similar to command line options) that are used internally by sqlay_php objects.

FUNCTIONS

Here are the functions which may be called inside pages. Mention may also be done of other functions which should theoretically NOT be used as they are very likely to change in future releases without notice.

Database functions:

Authentication Functions:

Application Functions:

Output Functions:

Page functions:

Dataobjects functions:

VARIABLES

SqLay behaviour is customized by the use of global arrays. As seen above, functions don't accept any (or almost) parameters, eventhough this may change in future releases (probably in a fashion similar to ncurses library, offering fully qualified functions but also shortcut functions using current objects defined in global variables).

The general behaviour is defined in a global array called $sqlay, documented in sqlay_config (5).

The menu system also uses a global array called $sqlay_menu which contains informations on the global (site wide) menu. This is also documented in sqlay_config (5) as all menu frames using it also need to know about the global menu.

All data object functions also use a global array called $table which contains a description of the database table or view around which the object operates. It is very likely that this would be changed into sqlay_table or something similar in future releases (in which case backward compatibility with existing code would be ensured as much as possible).

The main sub-array of the table array is called $table['fields'] which contains the description of the fields of the table or view.

Filling those arrays is considered to be mandatory before calling any database function.

Some variables may accept a list which is a coma separated string, i.e. action list may be 'add,list'.

$table[ ] array indices:

$table[$action]['buttons'][ n ][ ] numbered sub-array indices for custom buttons:

$action refers to values of the GET parameter action. Meaninfull values are view, list, add, edit and search. Others are ignored.

$table['title'][ ] sub-array indices:

$table['header'][ ] sub-array indices:

$table['margin'][ ] sub-array indices:

$table['help'][ ] sub-array indices:

$table['events'][ ] sub-array indices:

$table['key'][ n ][ ] sub-array(s) indices:

n, starting at 0 should be given for each field of a compound primary key.

$table['fkey'][ n ][ ]. This array is used in master/detail pages by the detail table. Numbered sub-array(s) indices:

n, starting at 0 should be given for each field of a compound foreign key.

$table['groups'][ ]. This array is used in sheets to skip display of certain fields having same value among rows. Those are alpha level variables which may change in future releases. Sub-array(s) indices:

n, starting at 0 should be given for each group (whose amount is computed from the number of fields having the grouped flag set).

$table['fields'][ n ][ ] numbered sub-array indices:

n, starting at 0 should be given for each field of the $table['select'] query if any, or for each field of the underlying database table, unless $table['nbflds'] is set in which case nor processing nor display display will be done at least in sheets on fields numbered higher than this value.

$table['fields'][ n ]['label'][ ] sub-array indices:

NOTES

This page is currently not extremely accurate, a.o. some default values may be wrong (i.e. saying FALSE when it is TRUE) and should be checked.

Pls understand that this is an alpha release and there may be unexpected results in untested use of combination of variables. Also the API is not considered to be fixed, meaning that variables, functions names or parameters lists may change, eventhough in such cases, backward compatibility files would (hopefully :) be offered for at least one major version.

Risks of damaging your database by breaking the integrity of your data or allowing unauthorized access (SQL injection or Cross-Site Scripting) are present eventhough I do my best to minimize them. Please be aware of this and avoid too large exposure (currently no suited for Internet use, unless with most features disabled).

BUGS

See the NOTE above for important security warnings.

AUTHOR

E. Lurquin <sqlay@hitud.net>

SEE ALSO

sqlay(1), sqlayrc(5), the source code.




sqlay_php 0.8Dec 2008sqlay_php(3)