douju6850 2015-07-05 21:19
浏览 18

ZF2:pthreads - 传递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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?