Что не так с глобалом?
<?php
$dbOptions = [
'servername' => '127.0.0.1',
'username' => 'test',
'password' => 'test',
'database' => 'test',
];
$query = "SELECT COUNT(*) FROM `Users` WHERE `order_date` = ? AND `reject` = 1";
$types = 's';
$values = ['2019-04-07'];
$connection = new \mysqli(
$dbOptions['servername'],
$dbOptions['username'],
$dbOptions['password'],
$dbOptions['database']
);
$stmt = $connection->prepare($query);
$stmt->bind_param($types, ...$values);
$stmt->execute();
$meta = $stmt->result_metadata();
$params = [];
while ($field = $meta->fetch_field())
{
$params[] = &$row[$field->name];
}
$stmt->bind_result(...$params);
$result = [];
while ($stmt->fetch()) {
$result[] = $row;
}
var_dump($result);