1
mparkins
Undefined class name 'database'
  • 2004/9/20 11:48

  • mparkins

  • Just popping in

  • Posts: 5

  • Since: 2004/8/12


I'm working on my first module and having got the admin section working fine am now working on the front end. A user does a search and finds data in my module, clicks on the link and is directed to a normal XOOPS page called viewrecord.php

The top part of this file is like this:

<?php

include XOOPS_ROOT_PATH.'/mainfile.php';
include XOOPS_ROOT_PATH.'/header.php';
include XOOPS_ROOT_PATH.'/class/database/database.php';

function getAnyRecordViewTemplateId($idtable)
{
$db = &Database::getInstance();

// BLAH BLAH BLAH - SNIPPED

return $data['id'];
}

$idtemplate = getAnyRecordViewTemplateId($_REQUEST['idtable']);


Really the problem is in the first few lines - it gets as far as setting $db, but returns the error: Fatal error: Undefined class name 'database' in C:\dev\tool\sokkit\site\xoops\modules\directory\viewrecord.php on line 9

Its almost like its ignoring the database.php include ? I've tried typing in junk in the include line there and it doesn't error either?!!?

Please help, confused

Matt

2
Mithrandir
Re: Undefined class name 'database'

1. You don't need to include the database class files - that's done via the inclusion of mainfile.php

2. $db =& XoopsDatabaseFactory::getDatabaseConnection(); is the correct way to retrieve the database object.

3
mparkins
Re: Undefined class name 'database'
  • 2004/9/20 12:47

  • mparkins

  • Just popping in

  • Posts: 5

  • Since: 2004/8/12


Thanks, but the error persists on the same line except now in the form of:

Fatal error: Undefined class name 'xoopsdatabasefactory'

I really think that it seems to be ignoring the include statement...

4
mparkins
Re: Undefined class name 'database'
  • 2004/9/20 14:40

  • mparkins

  • Just popping in

  • Posts: 5

  • Since: 2004/8/12


Sussed it.

It was a directory issue - I changed the includes to remove the constant XOOPS_ROOT_PATH - it's actually blatently obvious what the problem is but has only struck me now because it was v hard to pin down where it was actually going wrong - it doesn't seem to error properly if mainfile.php isn't included.

XOOPS_ROOT_PATH is actually set when mainfile.php is included (no I don't know how I thought it was some kind of global constant before either). Removed now and it works fine.

Phew, that only wasted 4 hours - at least I'll know for next time.

Login

Who's Online

87 user(s) are online (70 user(s) are browsing Support Forums)


Members: 0


Guests: 87


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits