public function getCatStatusNewsletter() { $status = new \calavera\customerBundle\Entity\CatNewsletterStatus(); $dql = "select u from \\calavera\\customerBundle\\Entity\\CatNewsletterStatus u where u.status = 'subscribed'"; try { $query = $this->em->createQuery($dql); $status = $query->getOneOrNullResult(); } catch (\Doctrine\ORM\NoResultException $orme) { } catch (\Exception $e) { } return $status; }
public function findVoluntarioByCPF($cpf) { try { $dql = "select vol, usu from Entity\\Voluntario vol join vol.usuario usu where usu.cpf = ?1"; $query = $this->em->createQuery($dql); $query->setParameter(1, $cpf); $voluntario = $query->getOneOrNullResult(); return $voluntario; } catch (Exception $ex) { $this->CI->log->write_log('error', $ex->getMessage() . ' - voluntario_dao::findVoluntarioByCPF '); } return null; }
public function findAvaliadorByCPF($cpf) { try { $dql = "select ava, usu from Entity\\Avaliador ava join ava.usuario usu where usu.cpf = ?1"; $query = $this->em->createQuery($dql); $query->setParameter(1, $cpf); $avaliador = $query->getOneOrNullResult(); return $avaliador; } catch (Exception $ex) { $this->CI->log->write_log('error', $ex->getMessage() . ' - avaliador_dao::findAvaliadorByCPF '); } return null; }
public function findOuvinteByCPF($cpf) { try { $dql = "select ouv, usu from Entity\\Ouvinte ouv join ouv.usuario usu where usu.cpf = ?1"; $query = $this->em->createQuery($dql); $query->setParameter(1, $cpf); $ouvinte = $query->getOneOrNullResult(); return $ouvinte; } catch (Exception $ex) { $this->CI->log->write_log('error', $ex->getMessage() . ' - ouvinte_dao::findOuvinteByCPF '); } return null; }
/** * TODO: POSSIBLIDADE DE COLOCAR ESTE MÉTODO EM DAO PAI * * Possivel saída * [ * 1 => "2", * "idUsuario" => 534 * ] * @param type $orientador_id * @return type */ private function get_max_seq($orientador_id) { try { $query = $this->em->createQuery("select max(oc.seq), usu.idUsuario " . "from Entity\\OrientadorCampus oc join oc.orientador ori join ori.usuario usu where usu.idUsuario = :orientador_id "); $query->setParameter('orientador_id', $orientador_id); $max_seq = $query->getResult(); $max_seq = $max_seq == null ? 0 : $max_seq; $max_seq = $max_seq[0] == null ? 0 : $max_seq[0]; $max_seq = $max_seq[1] == null ? 0 : $max_seq[1]; } catch (Exception $ex) { $this->CI->log->write_log('error', $ex->getMessage() . ' - orientador_campus_dao::get_max_seq '); } return $max_seq; }
/** * TODO: POSSIBLIDADE DE COLOCAR ESTE MÉTODO EM DAO PAI * * Possivel saída * [ * 1 => "2", * "idUsuario" => 534 * ] * @param type $autor_id * @return type */ private function get_max_seq($autor_id) { try { $query = $this->em->createQuery("select max(ac.seq), usu.idUsuario " . "from Entity\\AutorCurso ac join ac.autor aut join aut.usuario usu where usu.idUsuario = :autor_id "); $query->setParameter('autor_id', $autor_id); $max_seq = $query->getResult(); $max_seq = $max_seq == null ? 0 : $max_seq; $max_seq = $max_seq[0] == null ? 0 : $max_seq[0]; $max_seq = $max_seq[1] == null ? 0 : $max_seq[1]; } catch (Exception $ex) { $this->CI->log->write_log('error', $ex->getMessage()); } return $max_seq; }
/** * Set default article image * * @param int $articleNumber * @param ImageInterface $image * * @return void */ public function setDefaultArticleImage($articleNumber, ArticleImage $image) { $query = $this->orm->createQuery('UPDATE Newscoop\\Image\\ArticleImage i SET i.isDefault = 0 WHERE i.articleNumber = :articleNumber'); $query->setParameter('articleNumber', $articleNumber)->execute(); $image->setIsDefault(true); $this->orm->flush($image); $this->orm->clear(); }
/** * Get renditions names used by packages * * @return array */ private function getPackageRenditionNames() { $names = array(); foreach ($this->orm->createQuery('SELECT p FROM Newscoop\\Package\\Package p')->getResult() as $package) { $id = $this->orm->getUnitOfWork()->getEntityIdentifier($package->getRendition()); $names[] = $id['name']; } return $names; }
public function getEmails() { $emailAddress = new EmailAddresses(); $result = array(); $dql = "select m from calavera\\customerBundle\\Entity\\EmailAddresses m"; try { $query = $this->em->createQuery($dql); $result = $query->getResult(); } catch (\Doctrine\ORM\NoResultException $exc) { echo $exc->getTraceAsString(); } return $result; }
private function createFlextrineQuery($flextrineQuery) { if (preg_match('/^\\S*$/', $flextrineQuery->dql)) { // This is a remote method, with the query generated by a PHP method in the service $methodName = "query_" . $flextrineQuery->dql; $query = $this->{$methodName}($flextrineQuery->params); } else { // The DQL was passed from the client $query = $this->em->createQuery($flextrineQuery->dql); // Insert any parameters if ($flextrineQuery->params) { $paramsArray = (array) $flextrineQuery->params; foreach ($paramsArray as $name => $value) { $query->setParameter($name, $value); } } } // Only SELECT queries are allowed if (substr(strtoupper($query->getDQL()), 0, 7) != "SELECT ") { throw new \Exception("You may only use the SELECT operator " . $query->getDQL()); } return $query; }
/** * Get messages of the queue. * * @param int $maxMessages * @param int $timeout * @param ZendQueue\Queue $queue * @param int $microtime */ protected function getMessages($maxMessages, $timeout, $queue = null, $microtime = null) { if (is_null($maxMessages)) { $maxMessages = 1; } if (is_null($timeout)) { $timeout = self::RECEIVE_TIMEOUT_DEFAULT; } $andWhere = ''; if ($queue instanceof Queue) { $andWhere = 'AND (m.queue = :queue) '; } $andWhere .= 'AND (q.maxRetries IS NULL OR (q.maxRetries = 0 AND m.failed = false) OR m.numRetries < q.maxRetries)'; // Search for all messages inside the timeout $sql = 'SELECT m ' . 'FROM Heri\\Bundle\\JobQueueBundle\\Entity\\Message m ' . 'LEFT JOIN m.queue q ' . 'WHERE (m.handle IS NULL OR m.handle = \'\' OR m.timeout + :timeout < :microtime) ' . $andWhere . ' ' . 'ORDER BY m.priority DESC'; $query = $this->em->createQuery($sql); $query->setParameter('timeout', (int) $timeout); $query->setParameter('microtime', (int) $microtime); if ($queue instanceof Queue) { $query->setParameter('queue', $this->getQueueEntity($queue->getName())); } $query->setMaxResults($maxMessages); return $query->getResult(); }
/** * @return int */ public function getRowsNum($entityName) { $entityName = $this->getEntityName($entityName); $num = (int) $this->em->createQuery("SELECT count(e) FROM " . $entityName . " AS e")->getSingleScalarResult(); return $num; }