/**
  * Remove all limitations for a policy
  *
  * @param mixed $policyId
  *
  * @return void
  */
 public function removePolicyLimitations($policyId)
 {
     $query = $this->handler->createSelectQuery();
     $query->select($this->handler->aliasedColumn($query, 'id', 'ezpolicy_limitation'), $this->handler->aliasedColumn($query, 'id', 'ezpolicy_limitation_value'))->from($this->handler->quoteTable('ezpolicy'))->leftJoin($this->handler->quoteTable('ezpolicy_limitation'), $query->expr->eq($this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'), $this->handler->quoteColumn('id', 'ezpolicy')))->leftJoin($this->handler->quoteTable('ezpolicy_limitation_value'), $query->expr->eq($this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'), $this->handler->quoteColumn('id', 'ezpolicy_limitation')))->where($query->expr->eq($this->handler->quoteColumn('id', 'ezpolicy'), $query->bindValue($policyId, null, \PDO::PARAM_INT)));
     $statement = $query->prepare();
     $statement->execute();
     $limitationIdsSet = array();
     $limitationValuesSet = array();
     while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
         if ($row['ezpolicy_limitation_id'] !== null) {
             $limitationIdsSet[$row['ezpolicy_limitation_id']] = true;
         }
         if ($row['ezpolicy_limitation_value_id'] !== null) {
             $limitationValuesSet[$row['ezpolicy_limitation_value_id']] = true;
         }
     }
     if (!empty($limitationIdsSet)) {
         $query = $this->handler->createDeleteQuery();
         $query->deleteFrom($this->handler->quoteTable('ezpolicy_limitation'))->where($query->expr->in($this->handler->quoteColumn('id'), array_keys($limitationIdsSet)));
         $query->prepare()->execute();
     }
     if (!empty($limitationValuesSet)) {
         $query = $this->handler->createDeleteQuery();
         $query->deleteFrom($this->handler->quoteTable('ezpolicy_limitation_value'))->where($query->expr->in($this->handler->quoteColumn('id'), array_keys($limitationValuesSet)));
         $query->prepare()->execute();
     }
 }
 /**
  * Creates a generalized query for fetching object state group(s)
  *
  * @return \ezcQuerySelect
  */
 protected function createObjectStateGroupFindQuery()
 {
     $query = $this->dbHandler->createSelectQuery();
     $query->select($this->dbHandler->aliasedColumn($query, 'default_language_id', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'id', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'identifier', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'language_mask', 'ezcobj_state_group'), $this->dbHandler->aliasedColumn($query, 'description', 'ezcobj_state_group_language'), $this->dbHandler->aliasedColumn($query, 'language_id', 'ezcobj_state_group_language'), $this->dbHandler->aliasedColumn($query, 'real_language_id', 'ezcobj_state_group_language'), $this->dbHandler->aliasedColumn($query, 'name', 'ezcobj_state_group_language'))->from($this->dbHandler->quoteTable('ezcobj_state_group'))->innerJoin($this->dbHandler->quoteTable('ezcobj_state_group_language'), $query->expr->eq($this->dbHandler->quoteColumn('id', 'ezcobj_state_group'), $this->dbHandler->quoteColumn('contentobject_state_group_id', 'ezcobj_state_group_language')));
     return $query;
 }