想问下这段代码是什么含义呀?-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

想问下这段代码是什么含义呀?

2017-03-28 09:40:22 2087 0

<?php
/** NotORM - simple reading data from the database

if (!interface_exists('JsonSerializable')) {

interface JsonSerializable {
    function jsonSerialize();
}

}

include_once dirname(__FILE__) . "/NotORM/Structure.php";
include_once dirname(__FILE__) . "/NotORM/Cache.php";
include_once dirname(__FILE__) . "/NotORM/Literal.php";
include_once dirname(__FILE__) . "/NotORM/Result.php";
include_once dirname(__FILE__) . "/NotORM/MultiResult.php";
include_once dirname(__FILE__) . "/NotORM/Row.php";

// friend visibility emulation
abstract class NotORM_Abstract {

protected $connection, $driver, $structure, $cache;
protected $notORM, $table, $primary, $rows, $referenced = array();

protected $debug = false;
protected $debugTimer;
protected $freeze = false;
protected $rowClass = 'NotORM_Row';
protected $jsonAsArray = false;
protected $isKeepPrimaryKeyIndex = FALSE; //@dogstar 20151230

protected function access($key, $delete = false) {
}

}

/** Database representation

  • @property-write mixed $debug = false Enable debugging queries, true for error_log($query), callback($query, $parameters) otherwise
  • @property-write bool $freeze = false Disable persistence
  • @property-write string $rowClass = 'NotORM_Row' Class used for created objects
  • @property-write bool $jsonAsArray = false Use array instead of object in Result JSON serialization
  • @property-write string $transaction Assign 'BEGIN', 'COMMIT' or 'ROLLBACK' to start or stop transaction
    */

class NotORM extends NotORM_Abstract {


/** Create database representation
* @param PDO
* @param NotORM_Structure or null for new NotORM_Structure_Convention
* @param NotORM_Cache or null for no cache
*/
function __construct(PDO $connection, NotORM_Structure $structure = null, NotORM_Cache $cache = null) {
    $this->connection = $connection;
    $this->driver = $connection->getAttribute(PDO::ATTR_DRIVER_NAME);
    if (!isset($structure)) {
        $structure = new NotORM_Structure_Convention;
    }
    $this->structure = $structure;
    $this->cache = $cache;
}

/** Get table data to use as $db->table[1]
* @param string
* @return NotORM_Result
*/
function __get($table) {
    return new NotORM_Result($this->structure->getReferencingTable($table, ''), $this, true);
}

/** Set write-only properties
* @return null
*/
function __set($name, $value) {
    if ($name == "debug" || $name == "debugTimer" || $name == "freeze" || $name == "rowClass" || $name == "jsonAsArray" || $name == 'isKeepPrimaryKeyIndex') {
        $this->$name = $value;
    }
    if ($name == "transaction") {
        switch (strtoupper($value)) {
            case "BEGIN": return $this->connection->beginTransaction();
            case "COMMIT": return $this->connection->commit();
            case "ROLLBACK": return $this->connection->rollback();
        }
    }
}

/** Get table data
* @param string
* @param array (["condition"[, array("value")]]) passed to NotORM_Result::where()
* @return NotORM_Result
*/
function __call($table, array $where) {
    $return = new NotORM_Result($this->structure->getReferencingTable($table, ''), $this);
    if ($where) {
        call_user_func_array(array($return, 'where'), $where);
    }
    return $return;
}

}

取消 提交回答
全部回答(0)
相关问答

5

回答

Spark 【问答合集】

社区小助手 2019-05-29 14:13:40 129398浏览量 回答数 5

170

回答

惊喜翻倍:免费ECS+免费环境配置~!(ECS免费体验6个月活动3月31日结束)

豆妹 2014-10-29 17:52:21 231820浏览量 回答数 170

145

回答

【新手入门】云服务器linux使用手册

fanyue88888 2012-11-26 17:14:18 159298浏览量 回答数 145

22

回答

爬虫数据管理【问答合集】

我是管理员 2018-08-10 16:37:41 148466浏览量 回答数 22

2

回答

mySQL数据库报错You have an error in your SQL syntax

落地花开啦 2016-02-14 16:09:24 133078浏览量 回答数 2

43

回答

【精品问答集锦】Python热门问题

小六码奴 2019-05-30 15:27:34 142461浏览量 回答数 43

251

回答

阿里云LNAMP(Linux + Nginx + Apache + MySQL + PHP)环境一键安装脚本

云代维 2014-02-14 15:26:06 309128浏览量 回答数 251

97

回答

Redhat/CentOS一键安装web环境全攻略

xiaofanqie 2011-08-11 14:51:38 124681浏览量 回答数 97

24

回答

【精品问答】python技术1000问(1)

问问小秘 2019-11-15 13:25:00 482727浏览量 回答数 24

14

回答

域名解析是正确的,但是网站打不开求助!

游客b4ezpaqg54gdq 2019-07-05 11:50:33 121918浏览量 回答数 14
+关注
0
文章
11
问答
问答排行榜
最热
最新
相关电子书
更多
OceanBase 入门到实战教程
立即下载
阿里云图数据库GDB,加速开启“图智”未来.ppt
立即下载
实时数仓Hologres技术实战一本通2.0版(下)
立即下载