2013-11-22 37 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(); 
} 

现在它的每个实例都是唯一的。

我希望这会有所帮助,祝你好运