| 제목 | 재사용 문의 | ||
|---|---|---|---|
| 글쓴이 | freeseamew | 작성시각 | 2015/05/30 01:11:24 |
|
|
|||
|
코드 재사용 관련 문의 드립니다.
function Todos_get(){
$table_name = 'todo';
// 재사용 코드 시작
if(! $this->post('page')) {
$page = 1;
}
else {
$page = $this->post('page');
}
if(! $this->post('order')) {
$order = '';
}
else {
$order = $this->post('order');
}
if(! $this->post('like')) {
$like = '';
}
else {
$like = $this->post('like');
}
if(! $this->post('where')) {
$where = '';
}
else {
$where = $this->post('where');
}
if(! $this->post('limit')) {
$limit = '';
}
else {
$limit = $this->post('limit');
}
$data = array(
'table_name' => $table_name,
'page' => $page,
'order' => $order,
'like' => $like,
'where' => $where,
'limit' => $limit
);
// 재사용 코드 종료
$users = $this->Auth_m->read_user_list($data);
if(! is_null($users)) {
$this->response(array('response' => $users), 200);
}
else {
$this->response(array('error' => 'no users'), 400);
}
}
위의 소드에서 // 재용용 코드 시작 ~ 종료에 해당하는 부분을 계속해서 반복하여 작성하는 일이 발생하는데요 혹시 이부분을 효율적으로 재사용하는 방법이 없는가 문의 드립니다. 무식하게 function code() { } 로 만들어 $this->code() 로 불러볼까 했지만 역시나 안되더군요 ㅜㅜ 그럼 도움 부탁드리겠씁니다. |
|||
| 태그 | 코드 재사용,재사용, | ||
| 다음글 | smtp메일 보내기, 코드는 문제없는데 특정 서버에서 ... (2) | ||
| 이전글 | Disallowed Key Characters.php_... (4) | ||
|
한대승(불의회상)
/
2015/05/31 14:22:09 /
추천
0
|
http://cikorea.net/user_guide_2.1.0/general/helpers.html
http://cikorea.net/user_guide_2.1.0/general/creating_libraries.html