i have 2 tables: "User" and "States". What i pretend to do, is to count how many users are from certain state, ie:
state total users santa fe 5 buenos aires 20
and so on.
I'm using codeigniter with doctrine, here's my code:
public function countByState(){
$this->qb = $this->em->createQueryBuilder();
$this->qb->select('s.state_id', $this->qb->expr()->count('u.state'))
->from('models\States', 's')
->leftJoin('s.state_id' , 'u')
->leftJoin('models\User', 'u')
->groupBy('s.state_id');
$query = $this->qb->getQuery();
$obj = $query->getResult();
return $obj;
}
and this is the error: Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message '[Semantical Error] line 0, col 76 near 'u LEFT JOIN models\User': Error: Class models\States has no association named state_id' in C:\Desarrollo\new_frame_doctrine\site\application\libraries\data\Doctrine\ORM\Query\QueryException.php on line 47