private function prepare_statement($stmt, $args=[]) {
		if (!$this->connection) {
			self::$logger->error(sprintf(
				"SQL: connection failed: '%s'.",
				json_encode($this->verified_params)));
			throw new SQLError(SQLError::CONNECTION_ERROR,
				$this->dbtype . " connection error.");
		}

		$conn = $this->connection;
		try {
			$pstmt = $conn->prepare($stmt);
		} catch (\PDOException $e) {
			self::$logger->error(sprintf(
				"SQL: execution failed: %s <- '%s': %s.",
				$stmt, json_encode($args),
				$e->getMessage()));
			throw new SQLError(
				SQLError::EXECUTION_ERROR,
				sprintf("Execution error: %s.", $e->getMessage()),
				$stmt, $args
			);
		}

		try {
			$pstmt->execute(array_values($args));
		} catch (\PDOException $e) {
			self::$logger->error(sprintf(
				"SQL: execution failed: %s <- '%s': %s.",
				$stmt, json_encode($args),
				$e->getMessage()));
			throw new SQLError(
				SQLError::EXECUTION_ERROR,
				sprintf("Execution error: %s.", $e->getMessage()),
				$stmt, $args
			);
		}

		return $pstmt;
	}
private function prepare_statement($stmt, $args=[]) {
		if (!$this->connection) {
			self::$logger->error(sprintf(
				"SQL: connection failed: '%s'.",
				json_encode($this->verified_params)));
			throw new SQLError(SQLError::CONNECTION_ERROR,
				$this->dbtype . " connection error.");
		}

		$conn = $this->connection;
		try {
			$pstmt = $conn->prepare($stmt);
		} catch (\PDOException $e) {
			self::$logger->error(sprintf(
				"SQL: execution failed: %s <- '%s': %s.",
				$stmt, json_encode($args),
				$e->getMessage()));
			throw new SQLError(
				SQLError::EXECUTION_ERROR,
				sprintf("Execution error: %s.", $e->getMessage()),
				$stmt, $args
			);
		}

		try {
			$pstmt->execute(array_values($args));
		} catch (\PDOException $e) {
			self::$logger->error(sprintf(
				"SQL: execution failed: %s <- '%s': %s.",
				$stmt, json_encode($args),
				$e->getMessage()));
			throw new SQLError(
				SQLError::EXECUTION_ERROR,
				sprintf("Execution error: %s.", $e->getMessage()),
				$stmt, $args
			);
		}

		return $pstmt;
	}
private function prepare_statement ( $ stmt , $ args = [ ] ) { if ( ! $ this -> connection ) { self :: $ logger -> error ( sprintf ( "SQL: connection failed: '%s'." , json_encode ( $ this -> verified_params ) ) ) ; throw new SQLError ( SQLError :: CONNECTION_ERROR , $ this -> dbtype . " connection error." ) ; } $ conn = $ this -> connection ; try { $ pstmt = $ conn -> prepare ( $ stmt ) ; } catch ( \ PDOException $ e ) { self :: $ logger -> error ( sprintf ( "SQL: execution failed: %s <- '%s': %s." , $ stmt , json_encode ( $ args ) , $ e -> getMessage ( ) ) ) ; throw new SQLError ( SQLError :: EXECUTION_ERROR , sprintf ( "Execution error: %s." , $ e -> getMessage ( ) ) , $ stmt , $ args ) ; } try { $ pstmt -> execute ( array_values ( $ args ) ) ; } catch ( \ PDOException $ e ) { self :: $ logger -> error ( sprintf ( "SQL: execution failed: %s <- '%s': %s." , $ stmt , json_encode ( $ args ) , $ e -> getMessage ( ) ) ) ; throw new SQLError ( SQLError :: EXECUTION_ERROR , sprintf ( "Execution error: %s." , $ e -> getMessage ( ) ) , $ stmt , $ args ) ; } return $ pstmt ; }
Prepare and execute statement.
Prepare and execute statement .