/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_SearchEntityTagDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Get all entities * * @param integer $first * @param integer $limit * @param string $entityType * @throws Exception * @return array */ public function getAllEntities($first, $limit, $entityType = null) { if (null != ($entities = $this->searchEntityDao->findAllEntities($first, $limit, $entityType))) { // get entities' tags foreach ($entities as &$entity) { if (null != ($tags = $this->searchEntityTagDao->findTags($entity['id']))) { foreach ($tags as $tag) { $entity['tags'][] = $tag->entityTag; } } } } return $entities; }
/** * Set entities status by tags * * @param array $tags * @param string $status * @return void */ public function setEntitiesStatusByTags(array $tags, $status) { $enityTags = BOL_SearchEntityTagDao::getInstance(); $params = array(':deleted_status' => self::ENTITY_STATUS_DELETED, ':status' => $status); $query = ' UPDATE ' . $enityTags->getTableName() . ' AS a INNER JOIN ' . $this->getTableName() . ' AS b ON a.' . BOL_SearchEntityTagDao::ENTITY_SEARCH_ID . ' = b.id AND b.' . self::STATUS . ' <> :deleted_status SET b.' . self::STATUS . ' = :status WHERE a.' . BOL_SearchEntityTagDao::ENTITY_TAG . ' IN (' . $this->dbo->mergeInClause($tags) . ')'; $this->dbo->query($query, $params); }