G
G
gachkydxvbgd2017-04-09 18:15:40
PHP
gachkydxvbgd, 2017-04-09 18:15:40

How to output phalcon+volt array?

So I give it to the volt array

class IndexController extends ControllerBase
{
    public function indexAction()
    {
        $robots = $this->db->fetchAll(
            "SELECT * FROM goods",
            \Phalcon\Db::FETCH_ASSOC
        );
        $this->view->products = $robots;
    }

So I output to index.volt
{% for product in products %}
    {{ product.name }}
{% endfor %}

{{dump(product)}}

Mistake
Notice: Trying to get property of non-object in D:\Soft\OpenServer\OpenServer\domains\cas.dev\app\cache\d__soft_openserver_openserver_domains_cas.dev_app_views_index_index.volt.php on line 3

array(4) { ["id"]=> string(1) "1" ["cat_id"]=> string(1) "1" ["name"]=> string(3) "asg" ["descr"]=> string(3) "gas" }

How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SimBioT19, 2017-04-09
@gachkydxvbgd

In volt, access to array elements as in PHP Through the dot, there will be an access to the property ==
category.name$category->name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question