Example #1
0
 public static function searchForRules($query, $showInternalInformation = false, $AHUser = null)
 {
     $conn = mysqli_connect(\AHContentBlockerServer\DATABASE_HOST, \AHContentBlockerServer\DATABASE_USERNAME, \AHContentBlockerServer\DATABASE_PASSWORD, \AHContentBlockerServer\DATABASE_NAME);
     if (!$conn || $conn->connect_errno) {
         throw new \AHContentBlockerServer\AHException('Could not connect to database.', \AHContentBlockerServer\AHException::DATABASE_CONNECTION_FAILED);
     }
     $results = mysqli_query($conn, $query) or die(mysqli_error($conn));
     $returnInfo = [];
     while ($row = mysqli_fetch_assoc($results)) {
         $rule = new \AHContentBlockerServer\Rules\Rule(null, $AHUser);
         $rule->loadFromID($row['id']);
         $returnInfo[] = $rule->arrayFromRule($showInternalInformation);
     }
     return $returnInfo;
 }