/**
  * @param $query
  * @param $params
  * @throws ApplicationException
  * @return \PDOStatement
  */
 private function createResource($query, $params = null)
 {
     $queryString = $this->queryQuote($query, $params);
     Logger::printf($queryString);
     /**
      * @var PDOStatement $resource
      */
     $resource = Event::applyFilters("database.pdo.statement.prepare", $this->pdo->prepare($queryString));
     if ($resource === false) {
         throw new ApplicationException($this->pdo->errorInfo()[2]);
     }
     $resource->execute();
     Event::callEventListeners("database.pdo.statement.executed", $resource);
     if ($resource->errorCode() !== "00000") {
         throw new ApplicationException($resource->errorInfo()[2]);
     }
     return $resource;
 }