当前位置: 动力学知识库 > 问答 > 编程问答 >

php - ZF2: pthreads - Passing PDO

问题描述:

This is my first time using pthreads.

I have a Controller that runs multiple threads. Each thread will do lots of processing, and it will wait for a file to download. Later, it will save to a database.

Previously in the controller I used to get an instance of the database connection using:

public function getAppTable() {

if (!$this->appTable) {

$sm = $this->getServiceLocator();

$this->appTable = $sm->get('AppTable');

}

return $this->appTable;

}

However if I try to do this in my Thread extending class, I'll get getServiceLocator is not defined due to the fact that the class does not extend Controller. I cannot pass $this->appTable to the Thread as PDO cannot be serialized or unserialized.

How can I get this to work?

分享给朋友:
您可能感兴趣的文章:
随机阅读: