Answer the question
In order to leave comments, you need to log in
Why does phalcon output Undefined variable?
the source
at first did everything, too, everything was deduced from the tutorial database,
then he created his own database, connected it and the warnings
started rolling Notice: Undefined variable: invo in .... 3
Warning: Invalid argument supplied for foreach() .... 3
index.volt
{{ content() }}
{% for contact in invo %}
<p>{{ contact.name }}</p>
{% endfor %}
class Invo extends \Phalcon\Mvc\Model
{
public function initialize(){
$this->setSource('contact');
}
}
public function indexAction(){
$invo = Invo::find();//при вар дампе значение не пусто, значит выводиться должно
$this->view->setVar("contact", $invo);
}
}
/**
* Подключение базы данных
*/
$di->set('db', function() use ($config){
return new DbAdapter($config["database"]->toArray()); //берём подключение из config.php
});
Answer the question
In order to leave comments, you need to log in
45 minutes of stupidity because of one line:$this->view->setVar("invo", $invo);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question