thinkphp中用pthread进行多线程编程,在多线程内访问数据库有问题

浏览:5129 发布日期:2015/09/15 分类:求助交流 关键字: 多线程 thinkPHP
thinkphp中用pthread进行多线程编程,在多线程内访问数据库有问题,
贴一点代码吧        $uid = $this->msgconfig ['sms'] ['user4']; // 分配给你的账号
        $pwd = $this->msgconfig ['sms'] ['pass4']; // 密码
        $content2 = $this->content;
        $content = rawurlencode ( $this->content ); // 短信内容
        $phonelist = array ();
        if (stripos ( $this->mob, ',' ) > - 1) {
            $phonelist = explode ( ',', $this->mob );
        } else {
            $phonelist [0] = $this->mob;
        }
        $agent = $_SERVER ['HTTP_USER_AGENT'];
        $borwser_type = getBrowser ( $agent );
        $client_os = getPlatform ( $agent );
        $ip = get_client_ip ();
        $ipinfo = get_ip_location_area ( $ip );
        foreach ( $phonelist as $key => $value ) {
            $data = array (
                    'phone' => $value,
                    'content' => $content2,
                    'ip' => $ip,
                    'ipinfo' => $ipinfo,
                    'add_time' => time (),
                    'borwser_info' => $agent,
                    'type' => 1,
                    'borwser_type' => $borwser_type,
                    'client_os' => $client_os 
            );
            $smsid = $this->logmodel->add ( $data );
            logg_r($this->logmodel->sql());
            $post_data = '&account=' . $uid . '&password=' . $pwd . '&mobile=' . $value . '&content=' . $content;
            $smsdata = curl_get_contents ( $this->target . $post_data );
            $json = xml_to_array ( $smsdata );
            $json = $json ['SubmitResult'];
            $smsid = $this->data ['smsid'];
            if ($smsid >> 0) {
                $updata = array (
                        'result' => $json ['code'],
                        'msg' => $json ['msg'] 
                );
                $this->logmodel->where ( 'id=' . $smsid )->save ( $updata );
            }
        }
保存数据库的时候,保存不了,我跟踪代码到了db驱动,有sql,但是就是不执行,求助
最佳答案
评论( 相关
后面还有条评论,点击查看>>