I'm just a newbie and finding out PhalconPHP.
In one example, I have three tables with MyISAM engine:
In /model/Teams.php
public function initialize()
{
$this->hasMany("teamID","TeamsLeagues","teamID");
}
In /model/Leagues.php
public function initialize()
{
$this->hasMany("leagueID","TeamsLeagues","leagueID");
}
In /model/TeamsLeagues.php
public function initialize()
{
$this->belongsTo("teamID","Teams","teamID");
$this->belongsTo("leagueID","Leagues","leagueID");
}
I want to show more the column League when display the Teams, how can I do that?
I try this but not succeed:
In /controllers/TeamsController.php
public function searchAction()
{
$numberPage = 1;
if ($this->request->isPost()) {
$query = Criteria::fromInput($this->di, "Teams", $_POST);
$this->persistent->parameters = $query->getParams();
} else {
$numberPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
$parameters = array();
}
$parameters["order"] = "teamID";
$teams = Teams::find($parameters);
if (count($teams) == 0) {
$this->flash->notice("The search did not find any teams");
return $this->dispatcher->forward(array(
"controller" => "teams",
"action" => "index"
));
}
$paginator = new Paginator(array(
"data" => $teams,
"limit"=> 25,
"page" => $numberPage
));
$this->view->page = $paginator->getPaginate();
}
In /view/teams/search.phtml
<tr>
<td><?php echo $team->teamID ?></td>
<td><?php echo $team->name ?></td>
<td><?php echo $team->teamsLeagues->name ?></td>
<td><?php echo $team->shortName ?></td>
<td><?php echo $team->logo ?></td>
<td><?php echo $team->description ?></td>
<td><?php echo $this->tag->linkTo(array("teams/edit/" . $team->teamID, "Edit")); ?></td>
<td><?php echo $this->tag->linkTo(array("teams/delete/" . $team->teamID, "Delete")); ?></td>
</tr>
It show notice: Notice: Undefined property: Phalcon\Mvc\Model\Resultset\Simple::$name in E:\xampp\htdocs\football\app\views\teams\search.phtml on line 32