2013-10-09 2 views
0

저는 PHP와 codeigniter.can에서 초보자입니다. 누구든지이 PHP 프로그램을 codeigniter 형식으로 만들 수 있습니까?누구나 codeigniter 형식으로 만들 수 있습니까?

if ($user_id > 0){ 
    $follow = array(); 
    $fsql = "select user_id from following 
      where follower_id='$user_id'"; 
    $fresult = mysql_query($fsql); 

    while($f = mysql_fetch_object($fresult)){ 
     array_push($follow, $f->user_id); 
    } 

    if (count($follow)){ 
     $id_string = implode(',', $follow); 
     $extra = " and id in ($id_string)"; 

    }else{ 
     return array(); 
    } 
+0

처럼 할 수
사용 avtice 기록이 확실히 도움이 될 것 :: http://ellislab.com/codeigniter/user-guide/ –

+0

codeigbiter 궁극적으로 PHP입니다. 코드 서명자 형식이 없습니다. 당신은 쿼리 빌더에 대해 묻고 있습니까? – itachi

답변

0
if ($user_id > 0) 
{ 
    $follow = array(); 
    $qry = "select user_id from following where follower_id='$user_id'"; 
    $res = $this->db->query(qry); 

foreach($res->result() as $row) 
{ 
    array_push($follow, $row->user_id); 
} 

if (count($follow)) 
{ 
    $id_string = implode(',', $follow); 
    $extra = " and id in ($id_string)"; 

} 
else 
{ 
    return array(); 
} 
} 
+0

그 working.thanks – ItsVibi

0

이 시도 :이 모델에서 수행되어야한다

if ($user_id > 0){ 
    $follow = array(); 
    $rs  = $this->db->select('user_id')->where('follower_id', $user_id)->get('following')->result_array(); 
    if(is_array($rs) && count($rs) > 0){ 
     $follow = array(); 
     foreach($rs as $key => $each){ 
      $follow[] = $each['user_id']; 
     } 
    } 
    if (count($follow)){ 
     $id_string = implode(',', $follow); 
     $extra = " and id in ($id_string)"; 
    }else{ 
     return array(); 
    } 

} 
0

. 이

function getFriends($user_id){ 

    return $this->db 
       ->select('user_id') 
       ->where('follower_id',$user_id) 
       ->get('following') 
       ->result_array() // for single object use row_array() 
} 
관련 문제