Example #1
0
function ssSetControler()
{
    include './index.php';
    isset($_GET['c']) ? $c = $_GET['c'] : ($c = $DEFAULT_CONTROLLER);
    isset($_GET['a']) ? $act = $_GET['a'] : ($act = $DEFAULT_ACTION);
    //访问控制器
    if (file_exists("./app/controller/" . $c . ".class.php")) {
        include_once "./app/controller/" . $c . ".class.php";
        try {
            $con = new $c();
            if (method_exists($con, $act)) {
                $con->{$act}();
            } else {
                throw new Exception("This class " . "'{$c}'" . " have no method of " . "'{$act}'");
            }
        } catch (Exception $e) {
            ssError($e->getMessage());
        }
    } else {
        ssError("This class " . "'{$c}'" . " is no exist");
    }
}
Example #2
0
 public function __construct()
 {
     include './app/config.php';
     if (!empty($DATABASE) && !empty($DATAUSER)) {
         $dsn = $DATATYPE . ":host=" . $DATAHOST . ";dbname=" . $DATABASE;
         try {
             self::$pdo = new PDO($dsn, $DATAUSER, $DATAPWD);
             self::$pdo->exec("SET names utf8");
             return true;
         } catch (PDOException $e) {
             ssError('数据库未连接成功,请检查配置文件!');
             return false;
         }
     } else {
         return true;
     }
 }