From 0f70099a3e979b995399dcf8d719ba1dcf5c0c7d Mon Sep 17 00:00:00 2001 From: hbc Date: Wed, 17 Apr 2013 14:42:41 +0800 Subject: [PATCH] added load content --- application/models/tutor_model.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/application/models/tutor_model.php b/application/models/tutor_model.php index 97c097e..c1e6d09 100644 --- a/application/models/tutor_model.php +++ b/application/models/tutor_model.php @@ -11,14 +11,20 @@ class Tutor_model extends Content_model * * 根据 id 获取单条 tutor * - * @param int id + * @param int id + * @param bool load_content 是否获取内容 * @return 查询 result_array */ - public function get_by_id($id) + public function get_by_id($id, $load_content=False) { $this->db->from($this->model_tb_name)->where('id', $id); $query = $this->db->get(); - return $query->result_array(); + $ret = $query->result_array(); + if ($ret) + $ret = $ret[0]; + if ($load_content && $ret['content_id']) + $ret['content'] = $this->get_content($ret['content_id']); + return $ret; } /*