TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   My OOP Project (http://www.talkphp.com/advanced-php-programming/5406-my-oop-project.html)

Torsten 05-12-2010 06:39 AM

My OOP Project
 
Hello Community,

There is something wrong with my Project.
The Error Message is

"Fatal error: Call to a member function sendQuery() on a non-object in lib\page\IndexPage.class.php on line 9"

The Errormessage says that the Class for the DAL ( Database Abstaction Layer) is not initialized.

But the class is initialized in the CMSCore Class under

"lib/system/CMSCore.class.php".

The Error is only when I try to send an Query from the File

/lib/page/ANY_FILE.class.php

wenn I write the Statment in the index.php in the Root Dir it works.

Can everybody Help me?

If there are some Questions about the Project, how it should work, feel free to ask me.

I dont understand the error because the Template Engine is initialized at the same way and it works.

The hole Project is as an Attachment below.

Please make no Copy of this Project

Torsten 05-12-2010 10:30 AM

Can be closed, found the error by myself

Village Idiot 05-14-2010 03:32 AM

It would be helpful if you explained to others how you solved it.

Torsten 05-14-2010 01:09 PM

Ok.

The Error was in the Constructor of my Core Class.

PHP Code:

public function __construct(){
 
$this->initSessionFactory();
 
$this->initSessionHandler();
 
$this->initUserSession();
 
$this->initTemplateEngine();
 
$this->initRequestHandler();
 
$this->initDatabaseEngine();


PHP Code:

$this->initRequestHandler(); 

This Function calls the Class RequestHandler, where the $_REQUEST varibale is split into 2-4 static Variables

For an Example:
URL: index.php?page=Index

Result of RequestHandler:
$urlCategorie = page
$urlPage = Index

then the RequestHandler is including the page in "./lib/page/IndexPage.class.php"

I tried to fetch an DatabaseObject in this File but the initializtion of the Database wasn't done in the constructor of the Core Class.

so I fixed the Order of the constructor to

PHP Code:

public function __construct(){
 
$this->initSessionFactory();
 
$this->initSessionHandler();
 
$this->initUserSession();
 
$this->initTemplateEngine();
 
$this->initDatabaseEngine();
 
$this->initRequestHandler();


and it works.

It was an Runtime Error I think.


All times are GMT. The time now is 01:57 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0