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 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题