八月の星旧

不被嘲笑的梦想,是不值得去实现的!三十岁,一个刚刚好的年纪。

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
class OA {

    public static $oa = array();
    public static $config = array();

    public static function setConfig(array $config) {
        return self::$config = array_merge(self::$config, $config);
    }

    public static function user() {
        if (!key_exists('user', self::$oa) || !is_object(self::$oa['user'])) {
            //引入user.class.php
            self::$oa['user'] = new user();
        }
        return self::$oa['user'];
    }

  public static function goods() {
        if (!key_exists('user', self::$oa) || !is_object(self::$oa['goods'])) {
            //引入goods.class.php
            self::$oa['goods'] = new goods(); 
        } 
        return self::$oa['goods']; 
    }
}

//加载配置文件
OA::$config = array('dbname'=>'localhost','dbuser'=>'root','dbpassword'=>'123456');
OA::user()->get();
OA::goods()->set();

 

posted on 2014-08-27 13:50  八月の星旧  阅读(209)  评论(0)    收藏  举报