public function onData($data) { if ($this->currentMessage) { $overflow = $this->currentMessage->parseData($data); // json_encode can slow things down here //$this->debug("onData: " . json_encode($overflow) . ""); if ($overflow === false) { // there was not enough data to complete the message // leave this as the currentParser return; } $this->handleMessage($this->currentMessage); $this->currentMessage = null; if (strlen($overflow) > 0) { $this->onData($overflow); } return; } if (strlen($data) == 0) { return; } $type = $data[0]; $message = Message::createMessageFromIdentifier($type); if ($message !== false) { $this->currentMessage = $message; $this->onData($data); } // if (in_array($type, ['R', 'S', 'D', 'K', '2', '3', 'C', 'd', 'c', 'G', 'H', 'W', 'D', 'I', 'E', 'V', 'n', 'N', 'A', 't', '1', 's', 'Z', 'T'])) { // $this->currentParser = [$this, 'parse1PlusLenMessage']; // call_user_func($this->currentParser, $data); // } else { // echo "Unhandled message \"".$type."\""; // } }
public function encodedMessage() { $message = $this->portalName . ""; $message .= $this->statementName . ""; // next is the number of format codes - we say zero because we are just going to use text $message .= Message::int16(0); // // this would be where the param codes are added // $message = Message::int16(count($this->params)); // for ($i = 0; $i < count($this->params); $i++) { // // we are only going to use strings for right now // $message .= // } // parameter values $message .= Message::int16(count($this->params)); for ($i = 0; $i < count($this->params); $i++) { if ($this->params[$i] === null) { // null is a special case that just has a length of -1 $message .= Message::int32(-1); continue; } if ($this->params[$i] === false) { $this->params[$i] = 'FALSE'; } $message .= Message::int32(strlen($this->params[$i])) . $this->params[$i]; } // result column format codes - we aren't using these right now $message .= Message::int16(0); return 'B' . Message::prependLengthInt32($message); }
public function encodedMessage() { $msg = ""; $msg .= Message::int32($this->protocolVersion); foreach ($this->parameters as $k => $v) { $msg .= $k . "" . $v . ""; } $msg .= ""; return Message::prependLengthInt32($msg); }
public function encodedMessage() { return "P" . Message::prependLengthInt32($this->name . "" . $this->queryString . "" . ""); }
public function encodedMessage() { return "p" . Message::prependLengthInt32($this->password . ""); }
public function encodedMessage() { return "E" . Message::prependLengthInt32($this->portalName . "" . Message::int32(0)); // max rows - 0 is unlimited; }
public function encodedMessage() { return "C" . Message::prependLengthInt32("S" . $this->statementName . ""); }
public function encodedMessage() { $msg = Message::int32(80877103); return Message::prependLengthInt32($msg); }
public function encodedMessage() { return 'D' . Message::prependLengthInt32("{$this->portalOrStatement}{$this->name}"); }