[Flow] Simple database query
Bastian Waidelich
bastian at typo3.org
Wed Jan 7 14:57:20 CET 2015
On 07.01.15, at 09:03, Patric Eckhart wrote:
Hi Patric,
> public function myAction($email){
> $query = $this->doctrineQuery->getResult();
> $query->$this->doctrineQuery->matching($query->$this->doctrineQuery->equals($email))->setLimit(10)->execute();
> $this->view->assign('name', $query);
> }
With that you assign the $query to the view as "name", not the query result.
But more profoundly you mix up different tiers of your application. Flow
is quite opinionated. It can be a blessing if you get the hang of it and
follow its rules, but it will most probably cause a lot of work and
frustration if you don't.
Don't get me wrong. This is no criticism of course and in some cases
pragmatism is more important than concepts. But if you study the basic
concepts and programming models of Flow[1] you will most definitely
benefit from this.
It's a lot of information of course and it takes a lot of practice to
get it right, but it's worth it!
In this very case you probably want to use a repository so you can just
write:
$this->view->assign('user', $this->userRepository->findOneByEmail($email));
[1]
http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartI/Index.html
--
Bastian Waidelich
More information about the Flow
mailing list