2013-11-22 18 views
1

*庫正在調用2個函數。當我第二次調用它時,選擇第一個函數的數據。我想在第二個函數中重新加載庫。如何在Codeignator中重新加載庫?

public function impnewsdetail($ref) { 
    $url = array(
     'base' => $ref, 
     'category' => "" 
    ); 

    $this->load->library('crawler', $url); 
    $nd = $this->crawler->getNewsDetail(); 
    $newsdetail = array(
     'detail_heading' => $nd['detail_heading'], 
     'detail_tags' => $nd['detail_tags'], 
     'detail_date' => $nd['detail_date'], 
     'detail_image' => $nd['detail_image'], 
     'detail_image_detail' => $nd['detail_image_detail'], 
     'detail_text' => $nd['detail_text'] 
    ); 

    return $newsdetail; 
} 
+2

你的問題是缺乏信息。請告訴它第二個功能 –

回答

1

試試這個我不知道..

$this->load->library('crawler'); 
$mylib= new Mylib($url); 
$mylib->somemethod(); 
+0

它在哪裏工作。謝謝 –

1

也許你可以爲您加載的對象設置一個唯一的名稱。這可以這樣做:

function method1() 
{ 
    $this->load->library('crawler', $url, 'crawler1'); 

    $this->crawler1->method(); 
} 

function method2() 
{ 
    $this->load->library('crawler', $url, 'crawler2'); 

    $this->crawler2->method(); 
} 

現在它的每個實例都是唯一的。

我希望這會有所幫助,祝你好運