if (isset($_FILES['image'])) { require_once(dirname(__FILE__) . '/objects/Group.php'); $group = Group::getById($work->getId()); $result = DB::selectQuery('SELECT COUNT(*) as pcount FROM w_pictures WHERE work_id = ' . $work->getId()); $row = $result->fetchRow(); $num = $row['pcount']; $pic->setPhotoFromForm($_FILES['image'], $group->getName() . ' ' . $work->getName() . ' ' . $num++); } $description = htmlentities($_POST['description'], ENT_QUOTES, 'utf-8'); $pic->setDescription($description);
<?PHP require_once(dirname(__FILE__) . '/../base/DBObject.php');class Group extends DBObject { public $table = 'w_groups'; private $name = null; private $year = 2009; private $month = 1; private $day = 1; public static function create() { return new self(); } public static function getById($groupId) { $new = new self(); return $new->loadById($groupId); } public function makeObject($array = array()) { parent::makeObject($array); $this-> setName($array['name'])-> setYear($array['year'])-> setMonth($array['month'])-> setDay($array['day']); return $this; } protected function makeArray() { $arr = parent::makeArray(); $arr['name'] = $this->getName(); $arr['year'] = $this->getYear(); $arr['month'] = $this->getMonth(); $arr['day'] = $this->getDay(); return $arr; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; return $this; } public function getDay() { return $this->day; } public function setDay($day = 1) { $this->day = $day; return $this; } public function getMonth() { return $this->month; } public function setMonth($month = 1) { $this->month = $month; return $this; } public function getYear() { return $this->year; } public function setYear($year = 2009) { $this->year = $year; return $this; }
public static function getById($groupId){ $new = new self(); return $new->loadById($groupId);}
<?phprequire_once(dirname(__FILE__) . '/../base/DBObject.php');class Group extends DBObject { public $table = 'w_groups'; private $name = null; private $year = 2009; private $month = 1; private $day = 1; public static function create() { return new self(); } public static function getById($groupId) { $new = new self(); return $new->loadById($groupId); } public function makeObject($array = array()) { parent::makeObject($array); $this-> setName($array['name'])-> setYear($array['year'])-> setMonth($array['month'])-> setDay($array['day']); return $this; } protected function makeArray() { $arr = parent::makeArray(); $arr['name'] = $this->getName(); $arr['year'] = $this->getYear(); $arr['month'] = $this->getMonth(); $arr['day'] = $this->getDay(); return $arr; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; return $this; } public function getDay() { return $this->day; } public function setDay($day = 1) { $this->day = $day; return $this; } public function getMonth() { return $this->month; } public function setMonth($month = 1) { $this->month = $month; return $this; } public function getYear() { return $this->year; } public function setYear($year = 2009) { $this->year = $year; return $this; } }