@param Portfolio $portfolio
@param int       $nbResult
@param bool      $executeQuery

@return array|\Doctrine\ORM\Query
345988
public function findSome(Portfolio $portfolio, $nbResult = 10, $executeQuery = true)
    {
        $queryBuilder = $this->createQueryBuilder('pc')
            ->andWhere('pc.portfolio = :portfolio')
            ->setParameter('portfolio', $portfolio)
            ->setMaxResults($nbResult)
        ;

        return $executeQuery ? $queryBuilder->getQuery()->getResult() : $queryBuilder->getQuery();
    }
1348098
public function findRssDatas(Blog $blog, $executeQuery = true)
    {
        $query = $this->createQueryBuilder('post')
            ->select(['post'])
            ->andWhere('post.blog = :blogId')
            ->andWhere('post.status = :postStatus')
            ->andWhere('post.publicationDate IS NOT NULL')
            ->setParameter('blogId', $blog->getId())
            ->setParameter('postStatus', Statusable::STATUS_PUBLISHED)
            ->getQuery()
        ;

        return $executeQuery ? $query->getResult() : $query;
    }
570995
public function getAction(Request $request, User $loggedUser, Portfolio $portfolio, $type)
    {
        $this->checkPortfolioToolAccess($loggedUser, $portfolio);

        $data = [];

        /** @var \Icap\PortfolioBundle\Entity\PortfolioWidget[] $portfolioWidgets */
        $portfolioWidgets = $this->getWidgetsManager()->getPortfolioWidgetsForWidgetPicker($portfolio, $loggedUser, $type);

        foreach ($portfolioWidgets as $widget) {
            $data[] = $this->getWidgetsManager()->getPortfolioWidgetData($widget);
        }

        $response = new JsonResponse();
        $response->setData($data);

        return $response;
    }
1225959
public function search($query) {
        global $CFG;
        if ($result = parent::search($query)) {
            return $result;
        }

        $found = false;
        $portfolios = core_component::get_plugin_list('portfolio');
        foreach ($portfolios as $p => $dir) {
            if (strpos($p, $query) !== false) {
                $found = true;
                break;
            }
        }
        if (!$found) {
            foreach (portfolio_instances(false, false) as $instance) {
                $title = $instance->get('name');
                if (strpos(core_text::strtolower($title), $query) !== false) {
                    $found = true;
                    break;
                }
            }
        }

        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
381487
protected function executeQuery($query)
    {
        $query   = null !== $this->getLocale() ? sprintf('%s&language=%s', $query, $this->getLocale()) : $query;
        $content = $this->getAdapter()->get($query)->getBody();

        if (!$data = json_decode($content, true)) {
            throw new NoResult(sprintf('Could not execute query: %s', $query));
        }

        if (!isset($data['Response']) && 'InvalidCredentials' === $data['subtype']) {
            throw new InvalidCredentials(sprintf('Invalid credentials: %s', $data['details']));
        } elseif (!isset($data['Response'])) {
            throw new NoResult(
                sprintf('Error type `%s` returned from api `%s`', $data['subtype'], $data['Details'])
            );
        }

        if (empty($data['Response']['View'])) {
            throw new NoResult(sprintf('Could not find results for given query: %s', $query));
        }

        $locations = $data['Response']['View'][0]['Result'];

        $results = array();
        foreach ($locations as $location) {
            $location       = $location['Location'];
            $coordinates    = isset($location['NavigationPosition'][0]) ? $location['NavigationPosition'][0] : $location['DisplayPosition'];
            $bounds         = $location['MapView'];
            $address        = $location['Address'];
            $additionalData = $location['Address']['AdditionalData'];

            $results[] = array_merge($this->getDefaults(), array(
                'latitude'     => $coordinates['Latitude']  ?: null,
                'longitude'    => $coordinates['Longitude'] ?: null,
                'bounds'       => array(
                    'south' => $bounds['BottomRight']['Latitude']  ?: null,
                    'west'  => $bounds['TopLeft']['Longitude']     ?: null,
                    'north' => $bounds['TopLeft']['Latitude']      ?: null,
                    'east'  => $bounds['BottomRight']['Longitude'] ?: null,
                ),
                'streetNumber' => isset($address['HouseNumber']) ? $address['HouseNumber'] : null,
                'streetName'   => isset($address['Street'])      ? $address['Street']      : null,
                'city'         => isset($address['City'])        ? $address['City']        : null,
                'cityDistrict' => isset($address['District'])    ? $address['District']    : null,
                'zipcode'      => isset($address['PostalCode'])  ? $address['PostalCode']  : null,
                'county'       => isset($address['County'])      ? $address['County']      : null,
                'regionCode'   => isset($address['State'])       ? $address['State']       : null,
                'countryCode'  => isset($address['Country'])     ? $address['Country']     : null,
                'region'       => $this->findByKey('StateName', $additionalData),
                'country'      => $this->findByKey('CountryName', $additionalData),
                'countyCode'   => null,
            ));
        }

        return $results;
    }
1176653
public static function ExecuteAll($executeQueries)
	{
		$db = self::connect();
	
		$db->beginTransaction();
		$rowsAffected = 0;
		
		try
		{
			foreach($executeQueries as $executeQuery)
			{
				$query = $db->prepare($executeQuery["statement"]);
			
				foreach($executeQuery["parameters"] as $key => $parameter)
				{
					if(!isset($parameter["type"]))
						$parameter["type"] = PDO::PARAM_STR;
						
					$query->bindParam($key,$parameter["value"],$parameter["type"]);
				}
					
				$query->execute();
				$rowsAffected += $query->rowCount();	
			}
		}
		catch (PDOException $e)
		{
			$db->rollBack();
			$exception = "Sorry, there was a problem with query execution. ({$e->getMessage()})";
		}

		if($exception) throw new \Exception($exception);
		
		$db->commit();
		return $rowsAffected;
	}
219840
public function query($sql, $execute = FALSE)
    {

        $query = (empty($sql)) ? $this->query : $sql;
        $this->transactions[] = $this->replacePrefix($query); //just for reference

        //@TODO;
        if ($execute) {
            $this->exec($query);
        }

        return true;
    }
716456
public function getByPortfolioForGridster(Portfolio $portfolio, $inArray = false)
    {
        $portfolioWidgets = $this->entityManager->getRepository('IcapPortfolioBundle:PortfolioWidget')->findOrderedByRowAndCol($portfolio);

        if ($inArray) {
            $portfolioWidgetsInArray = [];
            foreach ($portfolioWidgets as $portfolioWidget) {
                $portfolioWidgetsInArray[] = $this->getPortfolioWidgetData($portfolioWidget);
            }

            $portfolioWidgets = $portfolioWidgetsInArray;
        }

        return $portfolioWidgets;
    }
915575
public function exec($sql = "", $bindingValues = array(), $insert = true)
    {
        //Check if the query is a SELECT|INSERT|UPDATE and :variation is available
        if (preg_match("/.*(SELECT|INSERT|UPDATE|SHOW|DELETE).*/", $sql)) {
            
            $this->sql = $sql;

            //Always prepare the SQL statement first
            $query = $this->connection->prepare($sql);

            if (preg_match('/\s*:(.+?)\s/', $sql)) {
                if (is_array($bindingValues) && !empty($bindingValues)) {
                    foreach ($bindingValues as $key => $val) {
                        //Clean the bindingValues. Check if they start with :
                        if (!preg_match('/:.*/', $key)) {
                            $bindingValues[":" . $key] = $val;
                            unset($bindingValues[$key]);
                        }
                    }
                }


                //Add the binding variables to the query
                if ($query->execute($bindingValues)) {
                    return $this->getLastInsertID();
                } else {
                    //@ToDo:When the save or update fails make sure we handle the error gracefully!
                    throw new \Exception(implode("\n", $query->errorInfo()));
                }

            } else {
                $result = $query->execute();
            }

            if (preg_match('/.*(SELECT|SHOW).*/', $sql)) {
                $query->setFetchMode(\PDO::FETCH_ASSOC);
                return $query->fetchAll();
            }

            return $result;
        }


        return false;
    }
125726
public function findNonPlatformRolesForUser(User $user, $executeQuery = true)
    {
        $dql = '
            SELECT r
            FROM Claroline\CoreBundle\Entity\Role r
            JOIN r.workspace w
            JOIN r.users u
            WHERE w.creator != :user
            AND u = :user
        ';

        $query = $this->_em->createQuery($dql);
        $query->setParameter('user', $user);

        return $executeQuery ? $query->getResult() : $query;
    }
776284
public function getPortfolioData(Portfolio $portfolio)
    {
        /** @var \Icap\PortfolioBundle\Entity\PortfolioWidget[] $portfolioWidgets */
        $portfolioWidgets = $this->widgetsManager->getByPortfolioForGridster($portfolio);
        /** @var \Icap\PortfolioBundle\Entity\PortfolioComment[] $comments */
        $comments = $this->entityManager->getRepository('IcapPortfolioBundle:PortfolioComment')->findSome($portfolio);

        $data = [
            'id' => $portfolio->getId(),
            'title' => $portfolio->getTitle(),
            'portfolioWidgets' => [],
        ];

        foreach ($portfolioWidgets as $portfolioWidget) {
            $data['portfolioWidgets'][] = $this->widgetsManager->getPortfolioWidgetData($portfolioWidget);
        }

        $commentsDatas = [];

        foreach ($comments as $comment) {
            $commentsDatas[] = $comment->getData();
        }
        $data['comments'] = $commentsDatas;
        $data['unreadComments'] = $portfolio->getCountUnreadComments();
        $data['commentsViewAt'] = $portfolio->getCommentsViewAt()->format(DATE_W3C);

        return $data;
    }
484545
public function exportAction($portfolioSlug, $format)
    {
        $this->checkPortfolioToolAccess();

        /** @var \Icap\PortfolioBundle\Entity\Portfolio $portfolio */
        $portfolio = $this->getDoctrine()->getRepository('IcapPortfolioBundle:Portfolio')->findOneBySlug($portfolioSlug);

        if (null === $portfolio) {
            throw $this->createNotFoundException('Unknown portfolio.');
        }

        $portfolioExporter = new Exporter($this->get('templating'));

        $widgets = $this->getWidgetsManager()->getByPortfolioForGridster($portfolio, false);
        $response = new Response($portfolioExporter->export($portfolio, $widgets, $format));
        $response->headers->set('Content-Type', 'text');

        return $response;
    }
801155
public function getMaskDecodersByTool(Tool $tool, $executeQuery = true)
    {
        return $this->maskRepo->findMaskDecodersByTool($tool, $executeQuery);
    }
741053
public function scopeFromDecadesAgo(Builder $query, $ago, $endDateTime = null)
    {
        return $this->scopeFromDateTimeRange(DateTime::getDecadesAgo($ago, $endDateTime));
    }
707058
protected function execute(string $query, array $bindings = [])
    {
        $query = N1qlQuery::fromString($query);
        $query->consistency($this->consistency);
        $query->crossBucket($this->crossBucket);
        $query->positionalParams($bindings);
        $result = $this->executeQuery($query);
        $this->metrics = $result->metrics ?? [];

        return $result;
    }
296566
public function load_data() {
        global $DB;
        if (!$this->cm = get_coursemodule_from_id('glossary', $this->id)) {
            throw new portfolio_caller_exception('invalidid', 'glossary');
        }
        if (!$this->glossary = $DB->get_record('glossary', array('id' => $this->cm->instance))) {
            throw new portfolio_caller_exception('invalidid', 'glossary');
        }
        if ($this->entryid) {
            if (!$this->entry = $DB->get_record('glossary_entries', array('id' => $this->entryid))) {
                throw new portfolio_caller_exception('noentry', 'glossary');
            }
            // in case we don't have USER this will make the entry be printed
            $this->entry->approved = true;
        }
        $this->categories = $DB->get_records_sql('SELECT ec.entryid, c.name FROM {glossary_entries_categories} ec
            JOIN {glossary_categories} c
            ON c.id = ec.categoryid
            WHERE ec.entryid = ?', array($this->entryid));
        $context = context_module::instance($this->cm->id);
        if ($this->entry->sourceglossaryid == $this->cm->instance) {
            if ($maincm = get_coursemodule_from_instance('glossary', $this->entry->glossaryid)) {
                $context = context_module::instance($maincm->id);
            }
        }
        $this->aliases = $DB->get_record('glossary_alias', array('entryid'=>$this->entryid));
        $fs = get_file_storage();
        $this->multifiles = array_merge(
            $fs->get_area_files($context->id, 'mod_glossary', 'attachment', $this->entry->id, "timemodified", false),
            $fs->get_area_files($context->id, 'mod_glossary', 'entry', $this->entry->id, "timemodified", false)
        );

        if (!empty($this->multifiles)) {
            $this->add_format(PORTFOLIO_FORMAT_RICHHTML);
        } else {
            $this->add_format(PORTFOLIO_FORMAT_PLAINHTML);
        }
    }
1123684
public function executeCriteriaLookup($in_is_expanding = false, $no_warnings = false)
    {
        ReporticoApp::set("code_area", "Criteria " . $this->query_name);
        $rep = new ReportArray();

        $this->lookup_query->rowselection = true;
        $this->lookup_query->setDatasource($this->datasource);
        $this->lookup_query->targets = array();
        $this->lookup_query->addTarget($rep);
        $this->lookup_query->buildQuery($in_is_expanding, $this->query_name, false, $no_warnings);
        $this->lookup_query->executeQuery($this->query_name);
        ReporticoApp::set("code_area", "");
    }