* Initializes a new instance of the ProfileComment class
*
* @param int $id the comment ID
*/
function__construct($id=''){
if($id){
$this->id=$id;
$this->load_from_database();
}else{
$this->date=time();
}
}
/**
* Loads the object comment (ie fill the properties) from the $_POST array
*/
functionload_from_form(){
if(array_key_exists('perso_id',$_POST)){
$this->perso_id=$_POST['perso_id'];
}
if(array_key_exists('author',$_POST)){
$this->author=$_POST['author'];
}
if(array_key_exists('date',$_POST)){
$this->date=$_POST['date'];
}
if(array_key_exists('text',$_POST)){
$this->text=$_POST['text'];
}
}
/**
* Loads the object comment (ie fill the properties) from the database
*/
functionload_from_database(){
global$db;
$id=$db->escape($this->id);
$sql="SELECT c.*, p.perso_name as author FROM ".TABLE_PROFILES_COMMENTS." c, ".TABLE_PERSOS." p WHERE c.comment_id = '$id' AND p.perso_id = c.comment_author";
if(!($result=$db->query($sql))){
message_die(SQL_ERROR,"Unable to query azhar_profiles_comments",'',__LINE__,__FILE__,$sql);