class 未找到-OOP
class not found-OOP
我正在观看有关使用 OOP 的 CMS 的教程 - PHP
我有错误但要检查它
我必须先检查 ArticlesCatsModel.php
在控制页面上:(ArticlesCatsModel.php)
class ArticlesCatsModel
{
public function Get($extra='')
{
$cats = array();
System::Get('db')->Execute("SELECT * FROM `articles_cats` {$extra}");
if(System::Get('db')->AffectedRows()>0)
$cats = System::Get('db')->GetRows();
return $cats;
}
}
$m = new ArticlesCatsModel();
$m->Get();
?>
当我 运行 时出现错误
Fatal error: Class 'System' not found in /var/www/html/cms/includes/models/ArticlesCatsModel.php on line 11
globals.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
define('ROOT', dirname(__FILE__));
define('INC', ROOT.'/includes/');
define('CORE', INC.'/core/');
define('MODELS', INC.'/models/');
define('CONTROLLERS', INC.'/controllers/');
define('LIBS', INC.'/libs/');
/**
* Core Files
*/
require_once(CORE.'config.php');
require_once(CORE.'mysql.class.php');
require_once(CORE.'raintpl.class.php');
require_once(CORE.'system.php');
System::Store('db', new mysql());
System::Store('tpl', new RainTPL());
?>
需要 ArticlesCatsModel.php 中的 globals.php。所以系统class可以用
require_once('path/to/globals.php');
class ArticlesCatsModel
{
public function Get($extra='')
{
$cats = array();
System::Get('db')->Execute("SELECT * FROM `articles_cats` {$extra}");
if(System::Get('db')->AffectedRows()>0)
$cats = System::Get('db')->GetRows();
return $cats;
}
}
// why the lines below in the same file?
$m = new ArticlesCatsModel();
$m->Get();
我认为classArticlesCatsModel
找不到globals.php
确保在调用 ArticlesCatsModel
class 时包含 globals.php
我正在观看有关使用 OOP 的 CMS 的教程 - PHP
我有错误但要检查它
我必须先检查 ArticlesCatsModel.php
在控制页面上:(ArticlesCatsModel.php)
class ArticlesCatsModel
{
public function Get($extra='')
{
$cats = array();
System::Get('db')->Execute("SELECT * FROM `articles_cats` {$extra}");
if(System::Get('db')->AffectedRows()>0)
$cats = System::Get('db')->GetRows();
return $cats;
}
}
$m = new ArticlesCatsModel();
$m->Get();
?>
当我 运行 时出现错误
Fatal error: Class 'System' not found in /var/www/html/cms/includes/models/ArticlesCatsModel.php on line 11
globals.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
define('ROOT', dirname(__FILE__));
define('INC', ROOT.'/includes/');
define('CORE', INC.'/core/');
define('MODELS', INC.'/models/');
define('CONTROLLERS', INC.'/controllers/');
define('LIBS', INC.'/libs/');
/**
* Core Files
*/
require_once(CORE.'config.php');
require_once(CORE.'mysql.class.php');
require_once(CORE.'raintpl.class.php');
require_once(CORE.'system.php');
System::Store('db', new mysql());
System::Store('tpl', new RainTPL());
?>
需要 ArticlesCatsModel.php 中的 globals.php。所以系统class可以用
require_once('path/to/globals.php');
class ArticlesCatsModel
{
public function Get($extra='')
{
$cats = array();
System::Get('db')->Execute("SELECT * FROM `articles_cats` {$extra}");
if(System::Get('db')->AffectedRows()>0)
$cats = System::Get('db')->GetRows();
return $cats;
}
}
// why the lines below in the same file?
$m = new ArticlesCatsModel();
$m->Get();
我认为classArticlesCatsModel
找不到globals.php
确保在调用 ArticlesCatsModel
class 时包含 globals.php