/** * Deletes any pet <=> color mappings for this color prior to deletion. * * @return bool **/ public function destroy() { $result = $this->db->query('DELETE FROM pet_specie_pet_specie_color WHERE pet_specie_color_id = ?', array($this->getPetSpecieColor())); if (PEAR::isError($result)) { throw new SQLError($result->getDebugInfo(), $result->userinfo, 10); } return parent::destroy(); }
/** * Delete a post and remove one from the user's postcount. * * Since this is called in a loop from BoardThead#destroy(), * I wrote the update SQL so it only has to do one query * instead of four. * * @ihatemysql * @return bool **/ public function destroy() { $result = $this->db->query('UPDATE user SET post_count = post_count - 1 WHERE user_id = ?', array($this->getUserId())); return parent::destroy(); }
/** * Set up the CSVIO instance. * * @param object See ActiveTable documentation. * @return void **/ public function __construct($db) { parent::__construct($db); if (strlen($this->quote) > 1) { throw new ArgumentError("Invalid quote character ({$this->quote}). The quote character may only be one character long or null."); } if (is_array($this->FIELDS) == false) { throw new ArgumentError('The field mapping list must be an array.'); } elseif (sizeof($this->FIELDS) <= 0) { throw new ArgumentError('The field mapping list cannot be empty.'); } else { // Validate & normalize field list. $this->FIELDS_NORMALIZED = $this->FIELDS; // For our purposes, the field list need only be 0 => foo; the 0 => array(...) needs to be normalized. foreach ($this->FIELDS_NORMALIZED as $index => $field) { if (is_array($field) == true) { if (array_key_exists('column', $field) == false) { throw new ArgumentError("Error in field {$index} - array given as value with no column defined."); } else { $this->FIELDS_NORMALIZED[$index] = $field['column']; } if (array_key_exists('format', $field) == true) { $FORMATS = array('date', 'datetime'); if (in_array($field['format'], $FORMATS) == false) { throw new ArgumentError("Invalid format '{$field['format']}' specified for column {$index} ('{$field['column']}')."); } } // end format is set } // end if field is array } // end field normalizer } // end field size looks OK; check in detail }
/** * Delete a thread and its associated posts. * * @return bool **/ public function destroy() { $posts = $this->grabPosts(); foreach ($posts as $post) { $post->destroy(); } return parent::destroy(); }
/** * Delete a staff group and its permission mapping. * * @return bool **/ public function destroy() { $result = $this->db->query('DELETE FROM staff_group_staff_permission WHERE staff_group_id = ?', array($this->getStaffGroupId())); if (PEAR::isError($result)) { throw new SQLError($result->getDebugInfo(), $result->userinfo, 10); } return parent::destroy(); }