• 初学Phreeze 6,reporter文件


    Phreezer.php里面的函数,
    public function IncludeModel($objectclass) { Includer::RequireClass($objectclass, array("Model/","Reporter/") ); }
    Query()方法里面有这句话
    1 $custom = $this->GetCustomQuery($objectclass, $criteria);

    调用了Phreezer.php里面的自身的方法GetCustomQuery();

    public function GetCustomQuery($objectclass, $criteria)
        {
            $this->IncludeModel($objectclass);
            $sql = call_user_func( array($objectclass,"GetCustomQuery"),$criteria );
    //上面这句话调用了用户自定义的GetCustomQuery方法,在Reporter.php里面
    return $sql; }
     
    PTestReporter.php的内容如下:

    require_once("verysimple/Phreeze/Reporter.php"); class PTestReporter extends Reporter{ public $Id; public $Name; public $Time; static function GetCustomQuery($criteria) { $sql = "select `ptest`.`id` as Id ,`ptest`.`name` as Name ,`ptest`.`time` as Time from `ptest`"; // the criteria can be used or you can write your own custom logic. // be sure to escape any user input with $criteria->Escape() $sql .= $criteria->GetWhere(); $sql .= $criteria->GetOrder();      //echo $sql; return $sql; } }
     */
        public static function RequireClass($classname, $classpath = "")
        {
            if (class_exists($classname)) return true;
            
            // normalize this as an array
            $classpaths = is_array($classpath) ? $classpath : array($classpath);
            $attempts = "";
    
            foreach ($classpaths as $path)
            {
                if (class_exists($classname)) break;
    //$classname='PTest';
    //$classpaths=array('Model/','Reporter/');
    try { // append a directory separater if necessary if ($path && substr($path,-1) != "/") $path .= "/"; Includer::IncludeFile($path . $classname . ".php"); //这里表示加载的页面,可是也没有说明可以加载Reporter.php的文件啊, } catch (IncludeException $ex) {$attempts .= " " . $ex->getMessage();} } if (!class_exists($classname)) { // the class still isn't defined so there was a problem including the model throw new IncludeException("Unable to locate class '$classname': " . $attempts); } }

    Query语句这么写:

    $ds=$this->Phreezer->Query('PTestReporter',$criteria);

    未完待续。。。。。。

  • 相关阅读:
    Spark学习之Spark Core
    Druid
    Spark学习之scala编程
    大数据学习之Zookeeper
    大数据学习之HBase
    大数据学习之Yarn
    大数据学习之Mapreduce
    运行spark sql时出现的一个问题
    大数据学习之Hive 简介安装与基本练习
    mysql
  • 原文地址:https://www.cnblogs.com/zhangjun516/p/2934975.html
Copyright © 2020-2023  润新知