Модель:Получить данные из автомобиля стола
Мои действия выглядит следующим образом:
public function fahrzeugeAction()
{
$user = $this->get('security.token_storage')->getToken()->getUser();
$userId = $user->getId();
$repository = $this->getDoctrine()
->getRepository('FPMAppBundle:Car');
/* This is the normal Select and it is testet with the mysqlworkbench.
SELECT c.id, c.description, c.active
FROM car c
INNER JOIN customer cu ON cu.id = c.id_customer
INNER JOIN customer_user cuu ON cuu.id_customer = cu.id
WHERE c.active = 1 AND cuu.id_user = 1
*/
$em = $this->getDoctrine()->getEntityManager();
$qb = $em->createQueryBuilder()
->select('c.id, c.description, c.active')
->from('Car', 'c')
->innerJoin('Customer', 'cu', 'ON', 'c.idCustomer = cu.id')
->innerJoin('CustomerUser', 'cuu', 'ON', 'cu.id = cuu.id_customer')
->where('cuu.idUser = ?', $userId)
->orderBy('c.id', 'ASC')
->getQuery();
$cars = $qb->getResult();
return $this->render("FPMAllgemeinBundle:Fahrzeuge:overview.html.twig"
array(
"cars" => $cars // I know that i have at the moment no variable named $cars
)
);
}
Внимание: get_class() ожидает параметр 1, чтобы быть объектом, число дано
Когда я использую обычный Select-Statement, тогда я получил право результат.
Использование 'createQueryBuilder()' вам нужно создать DQL not SQL, также обновите свой вопрос, добавив определение ваших сущностей –