function get_one($id) { $this->db->close_cache(); $sql = " SELECT * "; $sql .= " FROM " . $this->db->prefix . "list "; $sql .= " WHERE id='" . $id . "'"; $sql .= " AND status='1' "; $rs = $this->db->get_one($sql); if (!$rs) { $this->db->open_cache(); return false; } if ($rs["thumb_id"]) { $tmp_thumb = sys_format_list($rs["thumb_id"], "img"); $rs["thumb"] = $tmp_thumb[0]; unset($tmp_thumb); } $sql = "SELECT field,val FROM " . $this->db->prefix . "list_c WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $value["val"] = sys_format_content($value["val"]); $rs[$value["field"]] = $value["val"]; } } $this->db->open_cache(); return $rs; }
function get_one($id, $status = true, $pageid = 1) { $this->db->close_cache(); $sql = " SELECT m.* "; $sql .= " FROM " . $this->db->prefix . "list m "; $sql .= " WHERE m.id='" . $id . "'"; if ($status) { $sql .= " AND m.status='1' "; } $rs = $this->db->get_one($sql); if (!$rs) { $this->db->open_cache(); return false; } if ($rs["thumb_id"]) { $tmp_thumb = sys_format_list($rs["thumb_id"], "img"); $rs["thumb"] = $tmp_thumb[0]; unset($tmp_thumb); } //取得扩展字段信息,并对内容进行格式化 $sql = "SELECT e.field,e.val,m.input FROM " . $this->db->prefix . "list_ext e JOIN " . $this->db->prefix . "list l ON(e.id=l.id) JOIN " . $this->db->prefix . "module_fields m ON(l.module_id=m.module_id AND e.field=m.identifier) WHERE e.id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $rs[$value["field"]] = sys_format_list($value["val"], $value["input"]); } } unset($tmp_rs); $sql = "SELECT field,val FROM " . $this->db->prefix . "list_c WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $value["val"] = sys_format_content($value["val"], $rs, $pageid); $rs[$value["field"]] = $value["val"]; } } $this->db->open_cache(); return $rs; }
function get_one($id, $ext = "") { $sql = "SELECT l.*,m.if_thumb _if_thumb,m.inpic _inpic,m.if_biz _if_biz,c.inpic _inpic2 FROM " . $this->db->prefix . "list l JOIN " . $this->db->prefix . "module m ON(l.module_id=m.id) LEFT JOIN " . $this->db->prefix . "cate c ON(l.cate_id=c.id) WHERE l.id='" . $id . "'"; if ($this->phpok_rs["pic_required"]) { $sql .= " AND l.thumb_id>0 "; } if ($this->phpok_rs["attr"]) { $sql .= " AND l." . $this->phpok_rs["attr"] . ">0 "; } $rs = $this->db->get_one($sql); if ($ext && is_array($ext)) { $thumb_type = $rs["inpic"]; } else { $thumb_type = $rs["_inpic2"] ? $rs["_inpic2"] : $rs["_inpic"]; //如果有图片配置 } $rs["picture"] = $this->get_picture_one($rs["thumb_id"], $thumb_type); if ($rs["_if_biz"]) { //[判断是否有电子商务代码] $sql = "SELECT * FROM " . $this->db->prefix . "list_biz WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_one($sql); if ($tmp_rs) { $rs = array_merge($rs, $tmp_rs); } } //取得扩展字段信息 $sql = "SELECT e.field,e.val,m.input FROM " . $this->db->prefix . "list_ext e JOIN " . $this->db->prefix . "list l ON(e.id=l.id) JOIN " . $this->db->prefix . "module_fields m ON(l.module_id=m.module_id AND e.field=m.identifier) WHERE e.id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $rs[$value["field"]] = sys_format_list($value["val"], $value["input"]); } } unset($tmp_rs); $sql = "SELECT field,val FROM " . $this->db->prefix . "list_c WHERE id='" . $id . "'"; $tmp_rs = $this->db->get_all($sql); if ($tmp_rs && is_array($tmp_rs) && count($tmp_rs) > 0) { foreach ($tmp_rs as $key => $value) { $value["val"] = sys_format_content($value["val"]); $rs[$value["field"]] = $value["val"]; } } return $rs; }