parameter->setDefault('parentId=0&limit=0'); //如果没有cid值 if (!$this->parameter->parentId) { return; } /** 构建基础查询 */ $select = $this->select()->where('table.contents.type = ?', 'attachment'); //order字段在文件里代表所属文章 $select->where('table.contents.parent = ?', $this->parameter->parentId); /** 提交查询 */ $select->order('table.contents.created', Typecho_Db::SORT_ASC); if ($this->parameter->limit > 0) { $select->limit($this->parameter->limit); } if ($this->parameter->offset > 0) { $select->offset($this->parameter->offset); } $this->db->fetchAll($select, array($this, 'push')); } }