PHP Classes

File: includes/class.blog.php

Recommend this page to a friend!
  Packages of SPAM   pork.dbObject   includes/class.blog.php   Download  
File: includes/class.blog.php
Role: Class source
Content type: text/plain
Description: Example class: blog
Class: pork.dbObject
Map objects into MySQL database table rows
Author: By
Last change:
Date: 19 years ago
Size: 1,174 bytes
 

Contents

Class file image Download
<?

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>");
        

    }

}

?>