* search reports by search string * @param $searchString * @return array * @throws Exception */
($searchString)
| 353 | * @throws Exception |
| 354 | */ |
| 355 | public function search($searchString) |
| 356 | { |
| 357 | $sql = $this->db->getQueryBuilder(); |
| 358 | $sql->from(self::TABLE_NAME) |
| 359 | ->select('id') |
| 360 | ->addSelect('name') |
| 361 | ->addSelect('type') |
| 362 | ->addSelect('visualization') |
| 363 | ->where($sql->expr()->eq('user_id', $sql->createNamedParameter($this->userId))) |
| 364 | ->andWhere($sql->expr()->iLike('name', $sql->createNamedParameter('%' . $this->db->escapeLikeParameter($searchString) . '%'))) |
| 365 | ->orderBy('name', 'ASC'); |
| 366 | $statement = $sql->executeQuery(); |
| 367 | $result = $statement->fetchAll(); |
| 368 | $statement->closeCursor(); |
| 369 | |
| 370 | if ($result !== false && is_array($result)) { |
| 371 | foreach ($result as &$row) { |
| 372 | $row['type'] = (int) $row['type']; |
| 373 | } |
| 374 | unset($row); // Unset reference |
| 375 | } |
| 376 | |
| 377 | return $result; |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * get the report owner |