<?php

/*/
	(c) 2004 by Locke Enterprises (iLocke.com) - All rights reserved.
	License:  Authorized for use on the **[iLocke.com]** website.
	File:  NDB.phi  [v1.0]
	Purpose:  Include all necessary files in order to export the $g_oNDB object that is automatically connected.
	Created:  Nathan - 6/14/2004
	Modification History:
		* 6/25/2004 - Nathan - implement the new $g_Config{}
		* mm/dd/yyyy - [name] - [comment]
/*/

/*/
	DATA
		main:  mysqldump -u windshi_winddb --quote-names --password=parker --opt windshi_main > windshi_main.sql
		invoices:  mysqldump -u windshi_winddb --quote-names --password=parker --opt windshi_invoice > windshi_invoice.sql
	IMPORT:
		mysql -u windshi_winddb --password=parker windshi_main < windshi_main.sql
		mysql -u windshi_winddb --password=parker windshi_invoice < windshi_invoice.sql
/*/

	
	/*/ -- Be sure that we don't get include'd more than once. -- /*/
	if( isset($__NDB__) ) {
		echo "[NDB] Error(0a) Secondary inclusion attempt<br>\n";
		return(false);
	}
	$__NDB__ = true;

	/// establish where we will get the necessary files...
	if( !isset($NDB_Path) || $NDB_Path=="" ) {
		//!!! modify to just use: dirname(__FILE__)."/"
		$NDB_Path = (isset($g_Config->IncPath) && $g_Config->IncPath!="") ? $g_Config->IncPath."NDB/" : "../inc/NDB/";
	}
	
	/// handle a debugging...
	if( !isset($NDB_Debugging) ) $NDB_Debugging = false;
	if( $NDB_Debugging!==true ) {
		if( isset($g_Config->Debugging) ) {
			if( $g_Config->Debugging===true ) {
				$NDB_Debugging = true;
			}
		} else {
			$NDB_Debugging = false;
		}
	}
	if( $NDB_Debugging ) {
		echo "<!-- requiring NDB files at '".$NDB_Path."' -->";
		$NDB_prevReporting = error_reporting( E_ALL & ~E_NOTICE );
	}

	/// include the files...
	$bOK = true;

	$bOK = $bOK && include_once( $NDB_Path."oNDB.phi" );  // manages the connection and provides utility routines
	$bOK = $bOK && include_once( $NDB_Path."oNRS.phi" );  // manages opening and iterating recordsets
	$bOK = $bOK && include_once( $NDB_Path."oNQuery.phi" );  // manages opening and iterating recordsets

	/// create the NDB object and get it to automatically open a connection to the database...
	if( !isset($NDB_AutoConnect) ) $NDB_AutoConnect = true;
	if( $NDB_AutoConnect===true ) {
		$g_oNDB = new nDB( $g_Config->dbInfo['database'], $g_Config->dbInfo['user'], $g_Config->dbInfo['password'], $g_Config->dbInfo['server'], $NDB_Debugging );
	}

	/// return error_reporting how it was when we've been debugging...
	if( $NDB_Debugging ) error_reporting($NDB_prevReporting);

	/// all done...
	return true;	


