PConnect($host, $user, $passwd, $dbname)
or die( 'FATAL ERROR: Connection to database server failed' );
} else {
$db->Connect($host, $user, $passwd, $dbname)
or die( 'FATAL ERROR: Connection to database server failed' );
}
$ADODB_FETCH_MODE=ADODB_FETCH_BOTH;
}
function db_error() {
global $db;
if (! is_object($db))
dprint(__FILE__,__LINE__, 0, 'Database object does not exist.');
return $db->ErrorMsg();
}
function db_errno() {
global $db;
if (! is_object($db))
dprint(__FILE__,__LINE__, 0, 'Database object does not exist.');
return $db->ErrorNo();
}
function db_insert_id() {
global $db;
if (! is_object($db))
dprint(__FILE__,__LINE__, 0, 'Database object does not exist.');
return $db->Insert_ID();
}
function db_exec( $sql ) {
global $db;
if (! is_object($db))
dprint(__FILE__,__LINE__, 0, 'Database object does not exist.');
$qid = $db->Execute( $sql );
dprint(__FILE__, __LINE__, 10, $sql);
if ($msg = db_error())
{
global $AppUI;
dprint(__FILE__, __LINE__, 0, "Error executing:
$sql
");
// Useless statement, but it is being executed only on error,
// and it stops infinite loop.
$db->Execute( $sql );
if (!db_error())
echo '';
}
if ( ! $qid && preg_match('/^\