Source for file functions.inc.php
Documentation is available at functions.inc.php
* Set of functions used in the db_SQLite examples.
* @author Sascha 'SieGeL' Pfalz <php@saschapfalz.de>
* @version 0.10 (01-Feb-2009)
* $Id: functions.inc.php,v 1.4 2010/08/07 18:00:16 siegel Exp $
* @license http://opensource.org/licenses/bsd-license.php BSD License
ini_set('error_reporting' , E_ALL|
E_NOTICE|
E_STRICT);
* Load in the class definition based on used PHP version.
require_once('../db_sqlite.class.php');
* Returns an associative array with sapi-type name and required line break char.
* Use this function to retrieve the required line-break character for both the
* browser output and shell output. Currently only two keys are included:
* - "SAPI" => The sapi type of PHP (i.e. "cli")
* - "LF" => The line-break character to use (i.e. "<br>")
* @return array The associative array as described.
$data['HR'] =
"------------------------------------------------------------------------------\n";
* Prints out the amount of queries and the time required to process them.
* @param string $lf The linefeed character to use.
* @param mixed &$dbh The database object.
printf("%sQueries: %d | Time required: %5.3fs%s",$lf,$dbh->GetQueryCount(),$dbh->GetQueryTime(),$lf);
* Checks if given Object name exists inside the database.
* If checked object does not exist function can auto create the object if required DML is supplied
* @param mixed &$dbh The database object.
* @param string $objectname Name of object to check.
* @param string $dml_sql Required SQL to create the object if it does not exist.
* @return bool TRUE if Object exists else false.
$result =
$dbh->Query(sprintf("SELECT COUNT(*) AS CNT FROM sqlite_master WHERE NAME = '%s'",$objectname), SQLITE_ASSOC, 0, $objectname);
if(intval($result['CNT']) >
0)
/* If no sql to create object is supplied we return false as object does not exist. */
/* If $dml_sql != '' we try to create the object in question, and if this does not work we return false. */
$result =
$dbh->Query($dml_sql,SQLITE_ASSOC, 1);
$error =
$dbh->GetErrorText();
printf("SQLite ERROR: %s-%s%s",$result,$error,$d['LF']);
/* All is okay return true now. */
Documentation generated on Sat, 07 Aug 2010 20:01:04 +0200 by phpDocumentor 1.4.3