【发布时间】:2011-03-24 12:05:38
【问题描述】:
我有一个单例模式数据库对象,我想声明一次以在系统中使用。我有一个主要的包含文件,它提供所有单独的类文件并创建一些全局变量。
这是包含文件:
<?php
// Main API. We want to include everything here and then make some Global Vars:
require_once('database.class.php');
// Create the DB here:
$database = Database::Singleton();
require_once('user.class.php');
require_once('settings.class.php');
// Start the session:
session_start();
?>
理论上,$database 应该是一个全局变量,其后包含的任何东西都可以访问(即user.class.php 和settings.class.php。但是,当我尝试从Database 类中调用Database 类中的方法时@ 类如下:
$result = $database->FetchObject($queryString);
我收到以下错误:
致命错误:在 C:\Program Files (x86)\EasyPHP-5.3.4.0\www\PC Estimating\classes\user.class.php 中的非对象上调用成员函数 NumRows()在第 122 行
有人可以帮忙吗?
【问题讨论】: