Login   Register  
PHP Classes
elePHPant
Icontem

File: Post.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Orazio Principe  >  DB Persister  >  Post.php  >  Download  
File: Post.php
Role: Example script
Content type: text/plain
Description: Post example class
Class: DB Persister
Store and retrieve objects in database tables
Author: By
Last change:
Date: 2012-08-06 07:45
Size: 821 bytes
 

Contents

Class file image Download
<?php

/**
* Class referred to a mysql table like this:
*


CREATE TABLE `POSTS` (
  `idMessage` int(11) NOT NULL AUTO_INCREMENT,
  `subject` varchar(100) NOT NULL,
  `message` longtext NOT NULL,
  `dateCreated` datetime DEFAULT NULL,
  `dateEdited` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`idMessage`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8



*/
class Post extends DbMySql_Persister
{
    public 
$idMessage;
    public 
$subject;
    public 
$message;
    public 
$dateCreated;
    public 
$dateEdited;
    
    public function 
getPrimaryKey()
    {
        return 
"idMessage";
    }

    public function 
getTableName()
    {
        return 
"POSTS";
    }

    
    public function 
__toString()
    {
        return (string) 
$this->subject;
    }

}

?>