Multithreading Can';t使用pthreads访问线程类中的CI对象
无法获取CI对象的实例以使用thread类的run()函数中的模型 线程启动正常,但无法调用模型函数,请帮助Multithreading Can';t使用pthreads访问线程类中的CI对象,multithreading,codeigniter,pthreads,Multithreading,Codeigniter,Pthreads,无法获取CI对象的实例以使用thread类的run()函数中的模型 线程启动正常,但无法调用模型函数,请帮助 class Clinical extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('directory'); } public function index() {
class Clinical extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('directory');
}
public function index()
{
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
ini_set("max_execution_time", '0');
ini_set('memory_limit', '1024M');
$dirList = scandir('../clinicalTrial/');
$data["dirList"] = $dirList;
$this->load->view('clinical',$data);
}
public function import()
{
$folder = $_POST["folder_name"];
$dir = directory_map('../clinicalTrial/'.$folder);
$key = $folder;
$myThreadObj = new ClinicalThread($dir,$key);
var_dump($myThreadObj->start());
echo "Import Done";
exit;
}
}
class ClinicalThread extends Thread
{
public $dir = array();
public $key = "";
public function __construct($dir,$key)
{
$this->dir=$dir;
$this->key=$key;
}
function run()
{
$CI = & get_instance();
echo "";
print_r($CI);
exit;
if(!empty($this->dir))
{
foreach($this->dir as $file)
{
$CI->ct->extract($this->key,$file);
}
}
}
}
不能在线程内调用框架的模型函数,因为它不会在线程内加载框架引擎
请使用线程内的直接DB连接与数据库通信。这是我的第一个问题。我可能问得不正确。如果你对此有解决方案,请发表意见。调用线程开始()函数时,如何在线程运行()函数中使用模型。无意冒犯-这不是侮辱,相反,作为一个信息-因为如果你仔细阅读,你会偶然发现“帮助他人再现问题”一节,其中包含的代码刚好足以让他人再现问题并引用此链接-简单地说,请出示你的代码,因为没有人-绝对没有人-可以在看不到代码的情况下解决你的问题…谢谢你的回复。我已经编辑了代码,请您现在检查一下。。