sendPrepareQuery

Send a prepare query statement to the server.

@param  string     $identifier
@param  string     $sql
@return Connection $this
184121
public function sendPrepareQuery($identifier, $sql)
    {
        $this
            ->testQuery(
                pg_send_prepare($this->getHandler(), $identifier, $sql),
                sprintf("Could not send prepare statement «%s».", $sql)
            )
            ->getQueryResult(sprintf("PREPARE ===\n%s\n ===", $sql))
            ;

        return $this;
    }
480421
private static function executePrepareQuery($sqlstatement, array $data = [])
    {
        $pdostatement = static::$adapter
            ->getConnection()
            ->prepare($sqlstatement);

        static::$adapter->bind(
            $pdostatement,
            Sanitize::make($data, true)
        );

        $pdostatement->execute();

        $r = $pdostatement->rowCount();

        return $r;
    }
1198754
protected function getClientFromPool($sql)
    {
        return $this
            ->getSession()
            ->getClient(
                $this->getPoolerType(),
                PreparedQuery::getSignatureFor($sql)
            )
        ;
    }
559639
public function prepare($query)
    {
        $this->connect();
        $options = [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL];
        $isObject = $query instanceof Query;
        if ($isObject && $query->isBufferedResultsEnabled() === false) {
            $options = [];
        }
        $statement = $this->_connection->prepare($isObject ? $query->sql() : $query, $options);

        return new SqlserverStatement($statement, $this);
    }
1044041
protected function sendQuery(string $query)
    {
        if (self::$monitorQueries) {
            self::$queriesCount++;
        }
        $result = $this->link->query($query);
        if ($result === false) {
            throw new SqlException(
                'SQL-error [' . $this->link->errno . ']: ' . $this->link->error . "\nSQL-query: $query",
                $this->link->errno
            );
        }

        return $result === true ? $result : new Query\Result($result);
    }
992529
public function prepare(string $sql, array $params = []): Statement
    {
        if (!$stmt = sqlsrv_prepare($this->connection, $sql, $params)) {
            throw new SqlException('Query failed', sqlsrv_errors(), $sql, $params);
        }

        return new Statement($stmt, true, $sql, $params);
    }
1160233
protected function _prepareValue($value, SQL $SQL, $identifier = false){

		// Identifier should be string (purely a sanity-check, enforced elsewhere)

		assert('!(!is_string($value) && $identifier)');

		// String

		if(is_string($value)){

			// NULL

			if(strtoupper($value) == 'NULL'){

				$value = 'NULL';
			}

			// Identifier string

			elseif($identifier){

				/*
				 * Surround the identifier with "identifier quote characters"
				 * (either backtick or double quote, depending on SQL mode) and
				 * escape all further occurences of said character with itself.
				 */

				$quote = self::IDENTIFIER_QUOTE;
				$value = str_replace($quote, $quote . $quote, $value);

				$value = $quote . $value . $quote;
			}

			// Regular string

			else{

				$value = '\'' . $SQL->escapeString($value) . '\'';
			}
		}

		// Integer

		elseif(is_int($value)){

			$value = (string) $value;
		}

		// Floating-point

		elseif(is_float($value)){

			$value = (string) $value;

			// Ensure no (other) invalid characters are present

			assert('!preg_match(\'/[^\d.e+\-]/i\', $value)');
			$value = preg_replace('/[^\d.e+\-]/i', '', $value);
		}

		// Boolean (interpreted as INT(1))

		elseif(is_bool($value)){

			// Don't convert directly to string, (int) false === ''!

			$value = (string) ((int) $value);
		}

		// NULL

		elseif($value === null){

			$value = 'NULL';
		}

		// Array (interpret either as SET or as a list of ID's)

		elseif(is_array($value)){

			$is_string = null;

			$callback = function($value) use($SQL, &$is_string){

				// Values should be either string or integer

				assert('is_string($value) || is_int($value)');
				if(!is_int($value)) $value = (string) $value;

				// All values should be of the same type, no "mixed bags"

				assert('$is_string === null || is_string($value) === $is_string');

				if(is_string($value)) $is_string = true;

				return $SQL->escapeString($value);
			};

			array_map($callback, $value);

			$value = implode(',', $value);

			if($is_string) $value = "'{$value}'";
		}

		// Object

		elseif(is_object($value)){

			$value = '\'' . $SQL->escapeString(serialize($value)) . '\'';
		}

		// Invalid

		else{

			throw new QueryBuilderException('Data of type "' . gettype($value)
				. '" cannot be used in an SQL-query');
		}

		return $value;
	}
579805
private void connectAndPrepareStatement(Subscriber<? super T> subscriber, State state)
            throws SQLException {
        log.debug("connectionProvider={}", query.context().connectionProvider());
        if (!subscriber.isUnsubscribed()) {
            log.debug("getting connection");
            state.con = query.context().connectionProvider().get();
            log.debug("preparing statement,sql={}", query.sql());
            state.ps = state.con.prepareStatement(query.sql(), ResultSet.TYPE_FORWARD_ONLY,
                    ResultSet.CONCUR_READ_ONLY);
            if (query.context().fetchSize() != null) {
                state.ps.setFetchSize(query.context().fetchSize());
            }
            log.debug("setting parameters");
            Util.setParameters(state.ps, parameters, query.names());
        }
    }
837242
public function prepare(string $sql, $standalone = false)
    {
        try {
            $stmt = $this->dbh->prepare($sql);
            if ($standalone) {
                return $stmt;
            } else {
                $this->stmt = $stmt;
            }
            return $this;
        } catch (\PDOException $e) {
            die("Error: " . $e->getMessage());
        }
    }
21944
public static PreparedStatement prepareStatement(Connection conn, SqlBuilder sqlBuilder) throws SQLException {
		return prepareStatement(conn, sqlBuilder.build(), sqlBuilder.getParamValueArray());
	}
532272
public function premaintainQuery()
    {
        foreach ($this->pre_sql as $sql) {
            $nsql = Assignment::reporticoLookupStringToPhp($sql);
            $recordSet = false;
            $errorCode = false;
            $errorMessage = false;
            try {
                $recordSet = $conn->Execute($nsql);
            } catch (PDOException $ex) {
                $errorCode = $ex->getCode();
                $errorMessage = $ex->getMessage();
            }
            if (!$recordSet) {
                if ($errorMessage) {
                    ReporticoApp::handleError("Query Failed<BR><BR>" . $nsql . "<br><br>" .
                        $errorMessage);
                } else {
                    ReporticoApp::handleError("Query Failed<BR><BR>" . $nsql . "<br><br>" .
                        "Status " . $conn->ErrorNo() . " - " .
                        $conn->ErrorMsg());
                }

            }
        }

        $this->fetchColumnAttributes();

        // Run query for each target. Currently having more than
        // one target means first target is array which becomes source
        // for second target
        //for ($i = 0; $i < count($this->targets); $i++ )
        for ($i = 0; $i < 1; $i++) {
            $target = &$this->targets[$i];

            $target->setQuery($this);
            $target->setColumns($this->columns);
            $target->start();
        }
    }
1279989
protected function prepareEntity($entity, $identifier = false)
    {
        $label = (is_array($entity['label'])) ? $this->prepareLabels($entity['label']) : $entity['label'];

        if ($identifier)
        {
            // when the $identifier is used as a flag, we'll take care of generating it.
            if ($identifier === true) $identifier = $this->modelAsNode($entity['label']);

            $label = $identifier.$label;
        }

        $bindings = $entity['bindings'];

        $properties = [];
        foreach ($bindings as $key => $value)
        {
            // From the Neo4j docs:
            //  "NULL is not a valid property value. NULLs can instead be modeled by the absence of a key."
            // So we'll just ignore null keys if they occur.
            if (is_null($value)) continue;

            $key   = $this->propertize($key);
            $value = $this->valufy($value);
            $properties[] = "$key: $value";
        }

        return "($label { ". implode(', ', $properties) .'})';
    }
618805
public function getDeliveryExecution($identifier)
    {
        $query = $this->getQueryBuilder()
            ->select("*")
            ->from(self::TABLE_NAME)
            ->where(self::COLUMN_ID . " = :id")
            ->setParameter("id", $identifier)
        ;

        $result = $query->execute()->fetch();

        if (!$result) {
            $result = [];
        }

        return $this->parseQueryResult($result);
    }
511260
public static function prepare( $sql, $data ) {

		/**
		 * @var $wpdb wpdb
		 */
		global $wpdb;
		list( $sql, $data ) = apply_filters( 'pods_data_prepare', array( $sql, $data ) );

		return $wpdb->prepare( $sql, $data );
	}
1097752
public void send(final long identifier, final SpecificRecord message) {
    if (sender != null) {
      sender.onNext(serializer.write(message, identifier));
    } else {
      final String msgClassName = message.getClass().getCanonicalName();
      LOG.log(Level.SEVERE, "Attempt to send message [{0}] before network is initialized", msgClassName);
      throw new RuntimeException("NetworkTransport not initialized: failed to send " + msgClassName);
    }
  }
854553
public function query($sql, $bind = array())
    {
        $this->prepare($sql, $bind);

        return $this->db->query($sql, $bind);
    }
699244
public function query(string $sql, $bind = []): Statement
    {
        $this->operation = 'query';
        $this->params = $bind;
        $this->sql = $sql;
        return $this;
    }