![]() |
|
|
|
|
|
|
|
|
|
Version 1.x documentation | SF Project Page | downloads | support | bugs | NEWS | projects.
The base class of Orbit42.com is an opensource (free) project released with the hope that others would benifit from a class that contians the basics already. The project is hosted by sourceforge.net. If you like what you have been given please consider donating (see link at bottom of page) to cover some of the developer's time and to encurage said developer to focus on this project.
Some of the key design features include iterative functions that allow each child in the chain of extention to contribute without the need for complex namespace. This is achived by the hook function that allows a function to pass out it's vaiables by reference (in an array) without knowing what functions might in the furture exist to carry out actions on the data. Each class has a unique namespace for these functions based on the class name.
This callback method is vital to the design pattern of "loose coupling".
A number of features are marked "POSSIBLY BROKEN" this indicates that on inspection for documentation it seems that the code might not work as intended. This will be fixed in future BETA releases.
When creating a new system these settings may need to be set by your primary foundation class(es).
$callback an array that contains the details of a call back system that the class will use to pass on call backs. This flexable technique allowing for more than one type of call back and allows the developer of the system to select the callback handeling class.
$silence when set to true it suppresses callbacks. While not likely to figure largley in a system it may be usefull for simplifying very complex loops that need to make call back requests on some but not all itterations.
$db_conn and $db_used are variables used to track a database connection. It assumes that a connection object $db_conn and secondary connection data $db_used are needed. $db_used might be an array. This allows the class to be nostic of the database connection passing these values uninspected to the handler. In 2.x this is still the base class. In 3.x this might change.
$debug_on = [TRUE | FALSE]
$debug_level Like php itself errors are of differing levels of importance. The lower the number the more vital the information. The default is 1. This level displays only critical error messages. As a guide the following values are recomended:
1: CRITICAL ERRORS 2: WARNINGS (As 1 good for class testing) 3: NOTICES (As 2 but more so, good for class development) 4: As 3 but really verbose includes a lot of core stuff 5: AS 4 but really really talkative * These are used in core and offical classes to track data progess
function orbitbase_getversion returns a pipe "|" dilimted string with version information from classes and plugins. Use sparingly as on large systems this could require a lot of classes being called into memory.
function orbitbase_getdebuglv returns the debug level
function orbitbase_get_db_used returns the value of $db_used
function orbitbase_get_db_conn returns the value of $db_conn. With the above get it allows a "factory class" or other controller to duplicate the data store connection information from one class to another without needing to know it itself.
function data_store($table, $data=array()) POSSIBLY BROKEN Places the content of the array into the table given. The array must be simple (not nested).
function data_load($id, $idname, $table, &$arr=array()) This loads a record from $table where $idname = $id and palces it into $arr as an array. It is the matching brother of data_store.
function data_new($table, $data=array()) Primitive! adds the data from the array into a new row in $table.
data_new_advanced($table, $data, $idfield, $id=null) POSSIBLY BROKEN A wrapper for the data_new this one makes an attempt to identify the record and then load the array data back from the datastore incluing any automatic fields such as autonumber or timestamp that might have been added. Almost sertainly this could be improved and may require more complex code for some data stores as it relies heavily on a few php tricks to do it's job.
function hook($func, $data='', $debug_info="") replaces both extender_call and callback as functions you need to worry about. Provides a hook into your function. Ideally this should be available at least once in all key functions. Generally the more the merrier as they allow plugins and child classes to extend the functionality of the system without copy and paste.
function db_live_connect Equivilent of the constructor which your class may need to call if it carries a custom constructor function. Takes two arguments that corrispond to $db_conn and $db_used (in that order) both defaulting to 'none' (the default empty value for those two vars). These values are added tot he class scope and then db_connect is called insuring that a connection to a database exists.
function debug Works in conjunction with the variables $debug_on and $debug_level. It takes the following values $out, $array, $level. $out is required and is the output messge. $array is option and defaults to an empty string. If it is an array or an object the print_r function is called outputting the array content inside the pre html tags. $level defaults to 1 and should be set to a value that matches the usage. Values of 2 and 3 are generally suitable for deveopment or testing of a new class and can safely be left in a release candidate.
NB: Values above 1 can result in the headers already sent error and are therefore not suitable for a live system.
function db_sql_return_array($data, $arr = array(), $formof = 'assoc') a wrapper for the db_sql_return function but it carries out the standard fildling to get the returned rows into an array. It then gives you the array so that your class need only deal with the data itself.
function db_disconnect() this function must be written for your DB engine. It closes the connection. Generally you will want to leave this to some page controller object (depending on your projects design and specification).
Generally you will not want to call these yourself
function extender_call($func) Use hook instead. This allows basic classes to set aside user functions and have those functions used by successive generations of class without tripping over each other. This means that with each layer additional functionality can be added to the same action without any child ever overwritting the functionality of a parent.
function callback($event, $data=array(), $debug_info="") Use hook instead. This allows all objects to trigger events in any of it's parents it also allows all children to call an event manager. What does that mean? Just like the extender_call a call back gives the option of all generations haveing access to the data to act on it but a call back uses the $callback array to summon an instence of the call back handler to call external classe and functions.
function db_sql_return($data, $obj = '') this function must be written for your DB engine. It process the SQL command and returns an sql result. For day-to-day data retreval one should use the more refined db_sql_return_array
function db_connect() this function checks status of $db_conn and $db_used and connects if they do not contain a valid object. This has two advantages. A fall back connection setting and the ability to overwrite the connection settings with another set of connections. Further mroe a good constructor function could becreated to take objects such as $db_conn and $db_used from an earlier controller. (this function must be written for your DB engine).
function get_ancestors() passes back all of the classes parents in an ordered array back to the ORBIT42 Base class. This function is key to the entire functionality of the base class system.
function orbit_base($conn = 'none', $used = 'none') The parent constructor function.

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.