本文整理汇总了PHP中Doctrine::getEntityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine::getEntityManager方法的具体用法?PHP Doctrine::getEntityManager怎么用?PHP Doctrine::getEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine
的用法示例。
在下文中一共展示了Doctrine::getEntityManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
*
* @param string $action
* @param mixed $urlvalues
*/
public function __construct($action, $urlvalues)
{
$this->action = $action;
$this->urlvalues = $urlvalues;
// initialize the entityManage to be use by all child classes(Controller)
$this->entityManager = Doctrine::getEntityManager();
}
示例2: getEntityManager
/**
* Возвращает EntityManager
* @param bool $smart
* @param string $path_to_entity
* @param string $proxyPath
* @param string $proxyNamespace
* @return \Doctrine\ORM\EntityManager
*/
public static function getEntityManager($smart = FALSE, $path_to_entity = null, $proxyPath = null, $proxyNamespace = null)
{
return Doctrine::getEntityManager($smart, $path_to_entity, $proxyPath, $proxyNamespace);
}
示例3: getNextQuestion
/**
* Получает следующий вопрос, жаль что приходится в этом случае использовать нативный sql, но без него нормально не сделать
* @param Request $request
* @param Doctrine $doctrine
* @return array | bool true если вопросы закончились
*/
public static function getNextQuestion($request, $doctrine)
{
$session = $request->getSession();
$n = $session->get(self::CURRENT_QUESTION);
//если заданы все вопросы, вернуть true
if ($n == self::QUESTIONS_LIMIT) {
return true;
}
$result = array();
$notIn = $session->get(self::LAST_QUESTIONS, array(0));
$sNotIn = join(',', $notIn);
$rsm = new ResultSetMapping();
$rsm->addEntityResult('SkyengTT\\SkyengTTBundle\\Entity\\Vocabulary', 'v');
$rsm->addFieldResult('v', 'id', 'id');
$rsm->addFieldResult('v', 'eng_word', 'eng_word');
$rsm->addFieldResult('v', 'rus_word', 'rus_word');
$rsm->addFieldResult('v', 'answer_id', 'answer_id');
$questionResult = $doctrine->getEntityManager()->createNativeQuery("SELECT v.id, v.eng_word, v.rus_word, v.answer_id FROM vocabulary AS v WHERE v.id NOT IN ({$sNotIn}) ORDER BY RANDOM() LIMIT 1", $rsm)->getResult();
$answerLangWord = 'getRusWord';
$questionLangWord = 'getEngWord';
if (rand(0, 1000) % 2 != 0) {
$buf = $answerLangWord;
$answerLangWord = $questionLangWord;
$questionLangWord = $buf;
}
if ($questionResult) {
$question = current($questionResult);
$questionId = $question->getId();
$notIn[$questionId] = $questionId;
$session->set(self::LAST_QUESTIONS, $notIn);
$answerResult = $doctrine->getEntityManager()->createNativeQuery("SELECT v.id, v.eng_word, v.rus_word, v.answer_id FROM vocabulary AS v WHERE id != {$questionId} ORDER BY RANDOM() LIMIT 4", $rsm)->getResult();
$result['answers'] = array();
$result['question'] = array('id' => $question->getId(), 'word' => $question->{$questionLangWord}());
foreach ($answerResult as $item) {
if ($item->getId() != $question->getId()) {
$result['answers'][] = array('word' => $item->{$answerLangWord}(), 'id' => $item->getAnswerId());
}
}
$k = rand(0, 3);
$result['answers'][$k] = array('word' => $question->{$answerLangWord}(), 'id' => $question->getAnswerId());
}
$session->set(self::CURRENT_QUESTION, $n + 1);
return $result;
}
示例4: __construct
public function __construct(Doctrine $doctrine)
{
$this->em = $doctrine->getEntityManager();
}
示例5: fromQuery
/**
* Creates pager from query builder or query
*
* @param QueryBuilder $qb
* @param ParameterBag $params
*
* @return Pager
*/
public function fromQuery(QueryBuilder $qb, ParameterBag $params)
{
return $this->getNewPager($params, $this->doctrine->getEntityManager())->setQueryBuilder($qb);
}