<?
class Blog extends dbObject
{
function __construct($ID=false)
{
$this->__setupDatabase('blogs', // database table
array('ID_Blog' => 'ID', // database field => mapped object property
'strPost' => 'Story',
'datPosted' => 'Posted',
'strPoster' => 'Author',
'strTitle' => 'Title'),
'ID_Blog', // primary table key
$ID); // value of primary key to init with (can be false for new empty object / row)
$this->addRelation('Reaction'); // define a many:many relation to Reaction through Reaction
$this->addRelation('Tag', 'BlogTag');
}
function display()
{
$tagoutput = '';
$replyoutput = '';
$tags = $this->Find("Tag");
if($tags != false)
{
foreach($tags as $obj)
{
$tagoutput .= $obj->Tag." ";
}
}
$replies = $this->Find("Reaction");
if($replies != false)
{
foreach($replies as $obj)
{
$replyoutput .= $obj->display();
}
}
return("<fieldset><legend>{$this->Title}</legend>
<h3>by {$this->Author} @ {$this->Posted}</h3>
<p>{$this->Post}</p>
<p>Tags: {$tagoutput}</p>
<p>Replies:{$replyoutput}</p>
</fieldset>");
}
}
?>
|