【发布时间】:2010-03-28 15:11:58
【问题描述】:
我已经将一个普通的 PHP 类变成了一个库,所以我可以在 Codeigniter 中将它用作一个库。我可以加载它并在该类中调用我需要的函数。 Here is that class to help with the question。
但是,有很多地方我必须在课堂上调用函数。这些函数驻留在实例化我的类的模型中。我该如何做到这一点,因为目前正常的通话不起作用。这是我的代码:
class Controlpanel_model extends Model {
var $category = '';
var $dataa = 'a';
function Controlpanel_model(){
parent::Model();
}
function import_browser_bookmarks(){
$this->load->library('BookmarkParser');
/*
*In this function call to the class I pass
* what model functions exist that it should call
* You can view how this done by clicking the link above and looking at line 383
*/
$this->bookmarkparser->parseNetscape("./bookmarks.html", 0, 'myURL', 'myFolder');
return $this->dataa;
}
function myURL($data, $depth, $no) {
$category = $this->category;
$this->dataa .= 'Tag = '.$category.'<br />'.'URL = '.$data["url"].'<br />'.'Title = '.$data["descr"].'<br />'.'<br /><br />';
}
function myFolder($data, $depth, $no) {
$this->category = $data["name"];
}
}
感谢大家的帮助。
【问题讨论】:
标签: php model-view-controller codeigniter class