V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
V2EX  ›  ThisDay  ›  全部回复第 68 页 / 共 70 页
回复总数  1383
1 ... 60  61  62  63  64  65  66  67  68  69 ... 70  
❮ ❯
2015 年 8 月 31 日
回复了 ThisDay 创建的主题 › PHP › php 为什么能 foreache 到一个对象的受保护属性
@haiyang416 @freefcw @lijinma @solupro
首先是返回这个对象的方法。
```
/**
* Fetches all rows.
*
* @param string|array $where OPTIONAL An SQL WHERE clause
* @param string|array $order OPTIONAL An SQL ORDER clause.
* @param int $count OPTIONAL An SQL LIMIT count.
* @param int $offset OPTIONAL An SQL LIMIT offset.
* @return APP_Db_Table_Rowset_Abstract object
*/
public function fetchAll ($where = null, $order = null, $count = null, $offset = null )
{
$table = $this->_schema . '.' . $this->_db->quoteIdentifier ($this->_name );
$select = "SELECT * FROM $table";

// if ($where !== null )
if ($where !== null && !empty ($where ))
{
$select .= ' WHERE ' . $this->_where ($where );
}

if ($order !== null && !empty ($order ))
{
$select .= ' ORDER BY ' . $this->_order ($order );
}


if ($count !== null || $offset !== null )
{
$select = $select . $this->_db->limit ($count, $offset );
// $select = $this->_db->limit ($select, $count, $offset );
}

$data = $this->_fetch ($select );

require_once 'APP/Loader.php';
APP_Loader::loadClass ($this->_rowsetClass );
return new $this->_rowsetClass ($data );
}





```
然后是包含进来的 APP/Loader.php
```
<?php

/**
* @category APP
* @package APP_Loader
* @version $Id: Loader.php v1.0 2009-2-25 0:08:04 tomsui $
*/
class APP_Loader
{
/**
* Load a class
*
* Load a APP class file. If the class already exists in memory, return
* directly.
*
* @static
* @param string $class String name of the class to load.
* @param array $config OPTIONAL; an array with adapter parameters.
* @return void
* @throws APP_Exception
*/
public static function loadClass ($class )
{
if (class_exists ($class, false ) || interface_exists ($class, false )) {
return;
}

$file = str_replace ('_', DIRECTORY_SEPARATOR, $class ) . '.php';
self::_securityCheck ($file );

require ($file ) ;
}

/**
* Autoload switch
*
* if switch opens, APP class can be used without loading previously
*
* @static
* @param boolean $use to set wheather Autoload switcher in use or not.
* @return void
*/
public static function Autoload ($use = true )
{
if ($use ){
spl_autoload_register (array ('APP_Loader', 'loadClass'));
}else{
spl_autoload_unregister (array ('APP_Loader', 'loadClass'));
}

}

/**
* Security Check
*
* File name of APP classs can just contain alpha,digits,backslash (/),
* slash (\),underline (_),period (.) and dash (-). If contains other irregular
* charactor, an APP_Exception is thrown.
*
* @static
* @param boolean $filename the filename string to be check.
* @return void
* @throws APP_Exception
*/
protected static function _securityCheck ($filename )
{
if (preg_match ('/[^a-z0-9\\/\\\\_.-]/i', $filename )) {
require_once 'APP/Exception.php';
throw new APP_Exception ('Security check: Illegal character in filename');
}
}
}


```
2015 年 8 月 31 日
回复了 ThisDay 创建的主题 › PHP › php 为什么能 foreache 到一个对象的受保护属性
@haiyang416 对我就是是将该对象作为 foreach 的遍历参数。 iterator 接口如何实现的?整个对象就这么一个属性,没有任何方法,
2015 年 8 月 31 日
回复了 ThisDay 创建的主题 › PHP › php 为什么能 foreache 到一个对象的受保护属性
@timsims 我这里真能,我快疯了,不知道为啥。整个对象没有方法只有这么一个 protected 属性。
你直接 foreach $object 别 foreach ($object->_data )试试
你们这是招 PHP 程序员吗?直接招核心架构师的了
怎么看着都像是复制粘贴的招聘启示
2015 年 8 月 27 日
回复了 dhnUphp 创建的主题 › 程序员 › [mysql 插入缓慢]
把索引删了,手工建立另外的索引表
2015 年 8 月 26 日
回复了 haoli58 创建的主题 › 程序员 › php 程序员 1-3 年工作经验 五险一金
目测要求掌握这些的八九不离外包
2015 年 8 月 26 日
回复了 jtam 创建的主题 › JavaScript › 有偿求助,注册页面的图形验证码刷新
你直接贴代码,免费就帮你解决了,你这样扭扭捏捏,出 300 块也不一定有人干
2015 年 8 月 25 日
回复了 luoer 创建的主题 › PHP › help!有哪位大哥见过这种错误哇。
H,Պ9 这难道是个中文类名乱码了?
@SourceMan 那一旦需要抢购怎么办?突然增加的并发肯定影响客户体验,先暂停云服务吗?
云计算这么挣钱?连美团都来插一脚
2015 年 8 月 24 日
回复了 xuyl 创建的主题 › PHP › 关于 php curl 模拟登录的问题。。。。
我上次采集美丽说也是这个坑,返回的数据是 gzip 压缩过的,怎么调都是乱码
2015 年 8 月 24 日
回复了 kisshere 创建的主题 › 程序员 › v2ex 最初是怎么推广的?咋会聚集这么多程序员?
chrome 吧 火狐吧 知乎 V2EX 用户重合度很高,然后我在另外三个圈子都待过,自然而然就来这了
安卓 6.0 表示没有这个 bug ,添加新账户输入用户名密码
@caicai0126 在这下面配置Data\Packages\User 你说的那个配置路径是sublime text 2 的,没有的话就新建一个
2015 年 8 月 14 日
回复了 datxiaoy 创建的主题 › 程序员 › 现在 web 前端的都这么高吗
这跟我一个水平呀,但我主要是后端,前端就是副业
这个东西网上的教程都过时了,位置都不对,直接在插件配置目录改就行
2015 年 8 月 13 日
回复了 honkew 创建的主题 › Android › 求推荐手机,嘿嘿
Nexus6怎么没人推荐,虽然大点,但用起来确实爽
2015 年 8 月 13 日
回复了 TindleWei 创建的主题 › 求职 › 毕业一年投简历 Android 还是被虐成狗了
对于新人来说,简历还是写详细一点比较好
1 ... 60  61  62  63  64  65  66  67  68  69 ... 70  
❮ ❯
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1095 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 31ms · UTC 18:38 · PVG 02:38 · LAX 10:38 · JFK 13:38
♥ Do have faith in what you're doing.