BW Database

THIS PAGE HAS NOT BEEN COMPLETED BUT PROVIDES AN OUTLINE OF FUNCTIONALITY

This plugin is dependant on 'validation' (deprecated, forwarded to bwValidation (PHP)).

/config/config.php

 
$php_plugins = array(
	"all"=>array("database")
);
	 

It is an extensive framework for easily using PHP PDO, local query result caching (if exactly the same query), real-time data input updating and validating/restricting any database modifications based on anything you want. This is an essential plugin to learn and probably the largest. When you know the information below you will be able to create real-time data inputs, validate mysql queries, access a number of very useful functions for interacting with MySQL.

Over many years we have looked at all the database queries being executed and wanted to create not only an easy to use interface to interact with PDO objects, but also provide a stable platform for real-time updating with ease and validation.

/config/config.php

 
define("DB_HOST","YOUR_DB_HOST");
define("DB_NAME","YOUR_DB_NAME");
define("DB_USERNAME","YOUR_DB_USERNAME");
define("DB_PASSWORD","YOUR_DB_PASSWORD");
...
...
$php_plugins = array(
	"all"=>array("database")
);
	 

Once configured all the database methods will be available to you. But first let's go over some simple functions.

Example general function usage

 
//execute SQL directly from an SQL file
database::execFromFile($sqlFile,$db);

//There is a global variable $db that is your initial database connection to work with.
//For an additional connection:
$newDatabase = new database($host,$database,$username,$password);

//Other methods
//$fileName: name of the file (not a path)
//$force: always log whether debugging is on or off
$db->debug_log($message,$fileName,$force=false);
$db->column_exists($table,$column);

$db->execute($sqlString, $valuesArray, $returnArray, $useCache);
$db->db_add($tableName, $data);
$db->db_mod($tableName, $data, $WhereColumnEqualsArray, $whereAnd=true);
$db->db_del($tableName, $WhereColumnEqualsArray, $whereAnd=true);