public function __construct(array $options = null) { parent::__construct(); $this->last_id = 0; if (is_array($options)) { return $this->create($options); } return true; }
public static function delete($fname) { self::findBy("name='{$fname}'"); if (get_called_class() == 'Flat') { $flat = new Flat(); $flat->getFull($this->object_id); $photo_flat_path = $flat->getPhotoPath(); unlink($photo_flat_path . $fname); unlink($photo_flat_path . $fname . '_prev'); } parent::delete("name='{$fname}'"); }
public function __construct(array $options = null) { parent::__construct($options); }
public function update($values, $prefix = '') { $id = $this->id; $options = array(); $called_class = get_called_class(); foreach ($called_class::$_properties as $k => $v) { if (isset($values[$prefix . $k]) && $values[$prefix . $k] !== '') { if ($v['type'] == 'int') { $values[$prefix . $k] = str_replace(',', '.', $values[$prefix . $k]); $values[$prefix . $k] = str_replace(' ', '', $values[$prefix . $k]); $options[$k] = $values[$prefix . $k]; } else { $options[$k] = htmlspecialchars($values[$prefix . $k], ENT_NOQUOTES, 'UTF-8'); } } elseif (isset($v['type']) && $v['type'] == 'bool' && !isset($values[$prefix . $k])) { $options[$k] = 0; } } // если пользователь гость и объявление подавалось через агенство - уберем is_owner if (User::isGuest() && $this->user_id > 0 && !isset($_SESSION['admin'])) { $options['is_owner'] = 0; } parent::update($id, $options); $this->_vals['id'] = $id; }