|
下面是model里插入表的代码,怎样把它们提取出来显示成缩略图, 控制器中怎么写,视图中怎么写,各位大神们帮帮忙,我是菜鸟!
public function add_work_pic($uid, $pic)
{
$data = array();
$row = array();
if ($row = $this->db->where(array('uid' => $uid))->get($this->table)->row_array()) {
#直接在图片表里添加
$work_id = $row['id'];
} else {
#先添加work表,再添加图片表
$this->db->insert($this->table, array('uid' => $uid));
$work_id = $this->db->insert_id();
}
if ($pic['before_front_img']) {
$this->db->delete('picture', array('mark' => 'before_front_img', 'workid' => $work_id));
$data[0]['workid'] = $work_id;
$data[0]['path'] = $pic['before_front_img'];
$data[0]['mark'] = 'before_front_img';
}
if ($pic['before_side_img']) {
$this->db->delete('picture', array('mark' => 'before_side_img', 'workid' => $work_id));
$data[1]['workid'] = $work_id;
$data[1]['path'] = $pic['before_side_img'];
$data[1]['mark'] = 'before_side_img';
}
if ($pic['later_front_img']) {
$this->db->delete('picture', array('mark' => 'later_front_img', 'workid' => $work_id));
$data[2]['workid'] = $work_id;
$data[2]['path'] = $pic['later_front_img'];
$data[2]['mark'] = 'later_front_img';
}
if ($pic['later_side_img']) {
$this->db->delete('picture', array('mark' => 'later_side_img', 'workid' => $work_id));
$data[3]['workid'] = $work_id;
$data[3]['path'] = $pic['later_side_img'];
$data[3]['mark'] = 'later_side_img';
}
return $this->db->insert_batch('picture', $data);
}
|
|