DbServer::onReceive PHP Method

onReceive() public method

public onReceive ( $serv, $fd, $from_id, $data )
    public function onReceive($serv, $fd, $from_id, $data)
    {
        if ($this->isasync) {
            if (count($this->idle_pool) == 0) {
                //等待队列未满
                if (count($this->wait_queue) < $this->wait_queue_max) {
                    $this->wait_queue[] = array('fd' => $fd, 'sql' => $data);
                } else {
                    $this->http->send($fd, "request too many, Please try again later.");
                }
            } else {
                $this->doQuery($fd, $data);
            }
        } else {
            if ($this->multiprocess) {
                $result = $this->http->task($data);
            } else {
                $result = $this->http->taskwait($data);
            }
            $data_resp = array('status' => 'ok', 'error' => 0, 'errormsg' => '', 'result' => '');
            if ($result !== false) {
                $data_resp['result'] = $result;
                $this->http->send($fd, json_encode($data_resp));
            } else {
                $data_resp['error'] = 1;
                $data_resp['status'] = 'error';
                //$data_resp['errormsg']=sprintf("MySQLi Error: %s\n", mysqli_error($mysqli));
                $data_resp['result'] = array();
                $this->http->send($fd, json_encode($data_resp));
            }
        }
    }