db.php


#1

Dont know what to put in my db.php,

I’m getting this error,

fatal error: Undefined class name 'db' in c:programfileseasyphp1-8wwwCLockTableCmd.php on line 11

This is my CLockTableCmd.php

[php]<?php
require_once( “DB.php” );
require_once( “CCommand.php” );
require_once( “CUnlockTableCmd.php” );
require_once( “settings.php” );
class CLockTableCmd extends CCommand
{
function Execute( $sTableName )
{
// connect to the db
$db = DB::connect( $GLOBALS[‘g_PearDBDSN’] );
if (DB::isError( $db ))
{
// let everyone know that there has been a problem
$this->OnError("Failed to connect to the database using " . $GLOBALS[‘g_PearDBDSN’] . $db->getMessage());
// return failure
return CMD_ERROR;
}
// try to lock
$result = $db->Query( “LOCK TABLES $sTableName WRITE” );
if (DB::isError( $result ))
{
// let everone know there is a problem
$this->OnError(“Failed to lock $sTableName”);
// return failure
return CMD_ERROR;
} else {
// it is only if we reach this far that we
// need to worry about rolling back the command
$this->m_bNeedRollBack = true;
}
// this command is successfully completed
return CMD_FINISHED;
}
function OnRollBack()
{
// if we don’t need to roll back, don’t
if ( $this->m_bNeedRollBack == false )
{
return;
}
// create an instance of the unlock table command with no parent
$unlock = new CUnlockTableCmd( $null );
// execute it to unlock the table
$unlock->Execute( );
}
}
?>[/php]

Any help would be great thanks :)


#2

Where is the code that is (or should be) defining the DB Class?


#3

I dont know :o

I followed a book i bought but it never mentioned the db.php contents.


#4

Apparently the DB.php file is part of the PEAR installation, which is the method that you are using for database connection. For what ever reason, your php installation is not seeing this file.

Perhaps you can locate it (using something like slocate on linux, or windows explorer on a windoze platform) and put the absolute path in the require_once directive.