PHP Code:
<?php
class Gift {
// define properties
public $gid;
public function __construct() {
$this->gid = null;
$this->fields = array( 'title' => '',
'image' => '',
'price' => 0,
'category_title' => '');
}
// return an object populated based on the record's user id
public static function getById($gift_id) {
$gift = new Gift();
$row = mysql_fetch_assoc($res);
$gift->gid = $gift_id;
$gift->image = $row[gImage];
$gift->price = $row[gPrice];
$gift->hit = $row[gHit];
$gift->category = $row[gCat];
$rs = query("SELECT * FROM `gifts_category` WHERE `catid`=$row[gCat]");
$rw = mysql_fetch_assoc($rs);
$gift->category_title = $rw[catTitle];
mysql_free_result($res);
return $gift;
}
// save the record to the database
public function save() {
`gTitle`=\"$this->title\",
`gImage`=\"$this->image\",
`gPrice`=$this->price,
`gHit`=$this->hit,
`gCat`=$this->category
WHERE `gid`=$this->gid");
}
}
}
?>
Comment