Manages PDO connection and provides basic debugging functions.
- Put core/ into the root of your website.
- Create a config file for your server by duplicating or renaming core/db_con/localhost-example.php to core/db_con/HOSTNAME.php. E.g. localhost.php or example.com.php
- Update this file with your database connection details. Core comes with an empty sqlite database so to get going quickly all you need to do is set ROOT_DIR to the location of your web root directory on your server.
- Point your browser towards http://HOSTNAME/core/example.php
- Scroll down and you will either see "everything worked!" or some errors.
- If you have errors it's not my fault.
Setting up core in your script:
// Prevent direct access.
define('IN_SCRIPT', true);
// Include the class definition
require_once 'core.php';
// Instantiate
$core = Core::getInstance();
For further examples see core/example.php
Returns an instance of Core.
Executes an SQL query.
If the query is a SELECT query then an associative array will be returned. In all other cases a boolean is returned: true if the query was successful, false if not.
$params will be passed to PDO::execute() so should be formatted appropriately.
For debugging purposes.
Dumps the contents of a variable between PRE tags. If $name is specified it will be written out first. Sometimes handy if you're using write() a lot.
For debugging purposes.
Takes an array and writes it in nested divs with greyscale backgrounds representing the depth within the array. Works with n-dimension arrays.
Set $recurse to false to prevent it writing out the contents of arrays within the array.
Note: A hack is included to allow $GLOBALS to be passed to this function - anything with the key 'GLOBALS' will not be written out.
Starts the timer.
Returns the number of seconds elapsed since startTimer() was called. Returned value is a float to millisecond accuracy.
Logs the time taken since startTimer() was called to the log file defined in the config file.
Logs an error to the file specified in db_con/HOSTNAME.php. If $type is 5 then emails the error to the email address specified in the above file.
$type:
1 = Information
2 = Audit
3 = Security
4 = Debug
5 = Error
Sends an email to the email address specified in db_con/HOSTNAME.php.