Hi Fabio,
Thanks for your quick reply.
When I posted this error, I hadn't read the post about using the
Collection object instead of array in 0.7 (I was working from the
Quick Start guide, which still says to use arrays for *-to-many
relationships). I have made the changes to my code.
However, I am still getting what I think is a related error, whenever
I try to use the add() method on the Site::$pages Collection:
"Fatal error: Call to a member function add() on a non-object"
I suspect that I need to initialize the Site::$pages variable somehow,
so that it is a Collection and not null.
I am still in early stages of implementing my app using Outlet, but
here is my code so far.
Here are the entities, Site and Page:
<?php
class Site
{
public $ID;
public $SiteID;
public $Name;
private $pages; // somehow I need to initialize this??
public function getPages() { return $this->pages; }
public function setPages(Collection $pages) { $this->pages =
$pages; }
public function addPage(Page $page) { $this->pages->add($page); }
}
<?php
class Page
{
public $ID;
public $Name;
public $Description;
private $site;
public function getSite() { return $this->site; }
public function setSite(Site $site) { $this->site = $site; }
}
And here is my configuration:
<?php
return array
(
"connection" => <...>,
"classes" => array
(
"Site" => array
(
"table" => "sites",
"props" => array
(
"ID" => array("id", "int", array("pk" => true,
"autoIncrement" => true)),
"Name" => array("name", "varchar")
),
"associations" => array
(
array("one-to-many", "Page", array("key" => "SiteID"))
)
),
"Page" => array
(
"table" => "pages",
"props" => array
(
"ID" => array("id", "int", array("pk" => true,
"autoIncrement" => true)),
"SiteID" => array("site_id", "int"),
"Name" => array("name", "varchar"),
"Description" => array("description", "varchar")
),
"associations" => array
(
array("many-to-one", "Site", array("key" => "SiteID"))
)
)
)
);
Thanks,
Bob