You are here

public function InstapageCmsPluginDrupal8Connector::query in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/connectors/InstapageCmsPluginDrupal8Connector.php \InstapageCmsPluginDrupal8Connector::query()

Executes a SQL query.

@uses InstapageCmsPluginDrupal7Connector::prepare() to change '%s' to '?'.

Parameters

string $sql SQL to execute. %s can be used to output pre-formatted values. Values for %s can be passed as arguments for this function.:

Return value

bool True if the query is successful. DB error is logged and false if returned otherwise.

File

core/connectors/InstapageCmsPluginDrupal8Connector.php, line 99

Class

InstapageCmsPluginDrupal8Connector
Class that utilizes native Drupal 8 functions to perform actions like remote requests and DB operations.

Code

public function query($sql) {
  $args = func_get_args();
  array_shift($args);
  $args = $this
    ->prepareFunctionArgs($args);
  try {
    $statement = $this
      ->prepare($sql);
    if (count($args)) {
      return $statement
        ->execute($args);
    }
    else {
      return $statement
        ->execute();
    }
  } catch (Exception $e) {
    $this
      ->logDbError($e, $sql);
    return false;
  }
}