CI 프레임워크 개발 산기

1502 단어 아마추어
추가:
public function insert_code_relation($data) {
    $this->db->insert('code_relation', $data);
    return $this->db->insert_id();
}
  :
public function update_code($code, $data, $field = 'code') {
    $this->db->where($field, $code);
    $this->db->update('code', $data);
    return $this->db->affected_rows() > 0;
}

데이터를 가져오는 방법:
public function get_code_relation($code, $target_id, $code_type) {
    $query = $this->db->where(array('code' => $code, 'code_type' => $code_type, 'target_id' => $target_id))->get('code');
    return $query->row_array();
}

삭제:
public function delete_code_relation($keyword, $field = 'code') {
    $this->db->where(array($field => $keyword));
    $this->db->delete('code_relation');
}

 
질의:
//     
if (isset($params['where']) && $params['where']) {
    $this->db->where($params['where']);
}
if (isset($params['like']) && $params['like']) {
    $this->db->like($params['like']);
}
$total = $this->db->count_all_results('code_batch');
return array('total' => $total, 'limit' => $params['limit'], 'list' => $result ? $result : null);

좋은 웹페이지 즐겨찾기