doupeizheng3918 2015-08-08 19:45
浏览 33
已采纳

找不到类 - OOP

i'm watching a tutorials about CMS with OOP - PHP

i have error but to check it

i have to check ArticlesCatsModel.php first

on control page : (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();

?>  

when i run it i get error

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());
?>
  • 写回答

2条回答 默认 最新

  • dqayok7935 2015-08-08 19:51
    关注

    Require the globals.php in your ArticlesCatsModel.php. So the System class can be used.

    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();  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀