커뮤니케이션 모듈 스킨을 만지작 거리다가 아이디어가 떠올라서 한번 정리해봅니다.
{@ $oDB = DB::getInstance(); $stmt = $oDB->prepare('SELECT documents.* FROM documents WHERE documents.member_srl IN (SELECT target_srl FROM member_friend WHERE member_friend.member_srl = ?) AND status = ? ORDER BY documents.list_order ASC LIMIT 5'); $stmt->execute([$logged_info->member_srl, 'PUBLIC']); $result = $stmt->fetchAll(); $friend_document_list = []; if ( !empty($result) ): foreach ( $result as $attribute ): if ( !isset($GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]) ): $oDocument = new documentItem(); $oDocument->setAttribute($attribute, false); endif; $friend_document_list[] = $GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl]; endforeach; endif; }
그리고 이런 방법도 있는데요. 이건 total_count랑 페이지네이션도 잡아주네요ㅎ
{@ $oDB = DB::getInstance(); $stmt = $oDB->prepare('SELECT target_srl FROM member_friend WHERE member_srl = ?'); $stmt->execute([$logged_info->member_srl]); $result = $stmt->fetchAll(); $friend_document_list = []; if ( !empty($result) ): $member_srl_list = []; foreach ( $result as $val ): $member_srl_list[] = $val->target_srl; endforeach; $args = new stdClass; $args->member_srl = $member_srl_list; $args->list_count = 5; $args->statusList = ['PUBLIC']; $output = DocumentModel::getDocumentList($args); $friend_document_list = $output->data; endif; }