首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

展缓查询

2012-09-12 
延缓查询??phpclass SelectQuery {private $dbConnprivate $selectpublic function __construct($dbCon

延缓查询

?

<?phpclass SelectQuery {    private $dbConn;    private $select;        public function __construct($dbConn) {        $this->dbConn = $dbConn;        $this->select = $dbConn->select();    }        public function addField($col, $value, $op = '=', $join = 'and') {};        public function getLazyEntities() {        return new LazyQuery($this, 'findAll');    };        public function getLazyEntity() {        return new LazyQuery($this, 'find');    };        public function findAll() {        return $this->dbConn->fetchAll($this->select);    }        public function find() {        return $this->dbConn->fetchRow($this->select);    }}class LazyQuery {    private $query;    private $method;        public function __construct($query, $method) {        $this->query = $query;        $this->method = $method;    }        public function execute() {        $query = $this->query;        $method = $this->method;        if ($query && method_exists($query, $method)) {            return $query->$method();        }        throw new Exception("Query failed to call method.");    }}

热点排行