You are here

function execute_query in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 acsf_init/lib/cloud_hooks/acquia/db_connect.php \execute_query()

Helper function for mysqli query execute.

Parameters

mysqli $con: A link identifier returned by mysqli_connect() or mysqli_init().

string $query: An SQL query.

Return value

array|bool If query was successful, retrieve all the rows into an array, otherwise return FALSE.

1 call to execute_query()
uri.php in acsf_init/lib/cloud_hooks/acquia/uri.php

File

acsf_init/lib/cloud_hooks/acquia/db_connect.php, line 102
This file provides helper functions for running Acquia Cloud hooks.

Code

function execute_query(mysqli $con, $query) {

  // Acquia rules disallow mysqli_query() with dynamic arguments.
  // phpcs:disable
  $result = mysqli_query($con, $query);

  // phpcs:enable
  // If query failed, return FALSE.
  if ($result === FALSE) {
    return FALSE;
  }
  $rows = [];
  while ($row = mysqli_fetch_assoc($result)) {
    $rows[] = $row;
  }
  return $rows;
}