Esempio n. 1
0
 /**
  * Writes the record down to the log of the implementing handler
  *
  * @param  $record[]
  * @return void
  */
 protected function write(array $record)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     $content = ['channel' => $record['channel'], 'level_name' => $record['level_name'], 'message' => $record['message'], 'context' => json_encode($record['context']), 'extra' => json_encode($record['extra']), 'datetime' => $record['datetime']->format('Y-m-d G:i:s')];
     pg_get_result($this->connection);
     pg_send_execute($this->connection, $this->statement, $content);
 }
Esempio n. 2
0
 /**
  * sendExecuteQuery
  *
  * Execute a prepared statement.
  * The optional SQL parameter is for debugging purposes only.
  *
  * @access public
  * @param  string        $identifier
  * @param  array         $parameters
  * @param  string        $sql
  * @return ResultHandler
  */
 public function sendExecuteQuery($identifier, array $parameters = [], $sql = '')
 {
     $ret = pg_send_execute($this->getHandler(), $identifier, $parameters);
     return $this->testQuery($ret, sprintf("Prepared query '%s'.", $identifier))->getQueryResult(sprintf("EXECUTE ===\n%s\n ===\nparameters = {%s}", $sql, join(', ', $parameters)));
 }
Esempio n. 3
0
    pg_field_prtlen($result, 0);
    pg_field_is_null($result, 0);
    if (!pg_send_prepare($db, "php_test2", "INSERT INTO " . $table_name . " VALUES (\$1, \$2);")) {
        echo "pg_send_prepare() error\n";
    }
    while (pg_connection_busy($db)) {
    }
    // busy wait: intended
    if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
        echo "pg_connection_status() error\n";
    }
    if (!($result = pg_get_result($db))) {
        echo "pg_get_result() error\n";
    }
    pg_free_result($result);
    if (!pg_send_execute($db, "php_test2", array(9999, "A'BC"))) {
        echo "pg_send_execute() error\n";
    }
    while (pg_connection_busy($db)) {
    }
    // busy wait: intended
    if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
        echo "pg_connection_status() error\n";
    }
    if (!($result = pg_get_result($db))) {
        echo "pg_get_result() error\n";
    }
    pg_last_oid($result);
    pg_free_result($result);
}
pg_close($db);
Esempio n. 4
0
 /**
  * Execute a previously prepared statement asynchronously
  *
  * @param string $statementName
  * @param array $params
  * @return \Amp\Promise
  */
 public function execute(string $statementName, array $params)
 {
     if ($this->queryCacheSize > $this->maxOutstandingQueries) {
         return new \Amp\Failure(new \RuntimeException("Too busy"));
     }
     $deferred = new \Amp\Deferred();
     $this->queryCache[] = [self::$OP_QUERY_PARAMS, [$statementName, $params], $deferred];
     if (!$this->queryCacheSize++) {
         $sendResult = \pg_send_execute($this->db, $statementName, $params);
         $this->processSendResult($sendResult);
     }
     return $deferred->promise();
 }