Beispiel #1
0
 /**
  * @name fetchAll
  * @desc 执行SQL语句并返回全部数据
  * @param string $sql 要执行的sql语句
  * @param string $id 主键
  * @return array
  * @access public
  **/
 public function fetchAll($sql, $id = '')
 {
     $begin_microtime = Debug::getTime();
     try {
         $info = $this->db->fetchAll($sql, $id);
     } catch (Exception $e) {
         $this->halt($e, $sql);
         return false;
     }
     Debug::db($this->db_host, $this->db_name, $sql, Debug::getTime() - $begin_microtime, $info);
     return $info;
 }
 /**
  * 获取所有子孙ID
  *
  * @param integer $cateId
  * @return array
  */
 public function getAllChilds($cateId)
 {
     $childs = array();
     $select = $this->db->select()->from('category', 'cate_id')->where('parent_id = ?', $cateId);
     $res = $this->db->fetchAll($select);
     foreach ($res as $r) {
         $childs[] = $r['cate_id'];
         $subChilds = self::getAllChilds($r['cate_id']);
         $childs = array_merge($childs, $subChilds);
     }
     return $childs;
 }