| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- // +----------------------------------------------------------------------
- // | Fanwe 方维直播系统
- // +----------------------------------------------------------------------
- // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Author: 云淡风轻(1956838968@qq.com)
- // +----------------------------------------------------------------------
- //获取所有子集的类
- class child
- {
- public function __construct($tb_name)
- {
- $this->tb_name = $tb_name;
- }
- private $tb_name;
- private $childIds;
- private function _getChildIds($pid = '0', $pk_str='id' , $pid_str ='pid')
- {
- // $childItem_arr = $this->field('id')->where($pid_str."=".$pid)->findAll();
- $childItem_arr = $GLOBALS['db']->getAll("select id from ".DB_PREFIX.$this->tb_name." where ".$pid_str."=".$pid);
- if($childItem_arr)
- {
- foreach($childItem_arr as $childItem)
- {
- $this->childIds[] = $childItem[$pk_str];
- $this->_getChildIds($childItem[$pk_str],$pk_str,$pid_str);
- }
- }
- }
- public function getChildIds($pid = '0', $pk_str='id' , $pid_str ='pid')
- {
- $this->childIds = array();
- $this->_getChildIds($pid,$pk_str,$pid_str);
- return $this->childIds;
- }
- }
- ?>
|