Skip to content

Instantly share code, notes, and snippets.

@alborq
Created June 16, 2015 20:32
Show Gist options
  • Save alborq/768aa2e7462a936f42bd to your computer and use it in GitHub Desktop.
Save alborq/768aa2e7462a936f42bd to your computer and use it in GitHub Desktop.
<?php
namespace Shadow\WowBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function testAction()
{
//...
$repository = $this->getDoctrine()
->getManager()
->getRepository("WebDB:serveurState");
$OnlinePlayer = $repository->getLastServeurState();
//...
//...
//...
return $this->render('::debug.html.php',
array(
'var' => $OnlinePlayer
)
);
}
}
<?php
namespace Shadow\WowBundle\Repository\Char;
use Doctrine\ORM\EntityRepository;
class charactersRepository extends EntityRepository{
/* Permet de récuperer les joueur en ligne/faction
*
*/
public function getOnlinePlayerPerFaction()
{
$em = $this->getEntityManager();
$qb_a2 = $em->createQueryBuilder()
->select('count(c)')
->from('CharDB:characters', 'c')
->where('(c.race=2 OR c.race=5 OR c.race=6 OR c.race=8 OR c.race=9)')
->andWhere('c.online = 1');
$qb_a2->getQuery()->getSingleScalarResult();
$qb_h2 = $em->createQueryBuilder()
->select('count(c)')
->from('CharDB:characters', 'c')
->where('(c.race=1 OR c.race=3 OR c.race=4 OR c.race=7 OR c.race=10 OR c.race=11)')
->andWhere('c.online = 1');
$qb_h2->getQuery()->getSingleScalarResult();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment