We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

output the rowcount in the volt view

I am doing the following and wanted to output the rowcount in the volt view file, can someone help me with an example.

$robots = $robots::find(); $result = $robots->rowCount();

Am I doing it correctly, please let me know and if yes, I am always getting an error if I try to use any of these in the volt with {{ result }} or with {{robots |length}}, the error is undefined variable. Please help someone.



93.7k
Accepted
answer

you have to pass it to the view from your controller like so

$this->view->result = Robots::find();

Can you be more specific, I am unable to understand. I would really appreciate if you can do an example. I am sorry I am a newbie to phalcon and wanted to learn it.

you have to pass it to the view from your controller like so

$this->view->result = Robots::find();

can you show us your controller and volt code so we can show you where the problem is?

edited Nov '15

thank you so much, your answer did helped me over coming the issue that I was facing. I was not passing it to the view like you mentioned and hence getting that error.