/** * Delete an item. * * @return void * @param int $id The id of the record to delete. */ public static function delete($id) { // redefine $id = (int) $id; // get db $db = BackendModel::getDB(true); // get field ids $fieldIds = (array) $db->getColumn('SELECT i.id FROM forms_fields AS i WHERE i.form_id = ?', $id); // we have items to be deleted if (!empty($fieldIds)) { // delete all fields $db->delete('forms_fields', 'form_id = ?', $id); $db->delete('forms_fields_validation', 'field_id IN(' . implode(',', $fieldIds) . ')'); } // get data ids $dataIds = (array) $db->getColumn('SELECT i.id FROM forms_data AS i WHERE i.form_id = ?', $id); // we have items to be deleted if (!empty($dataIds)) { self::deleteData($dataIds); } // delete extra BackendModel::deleteExtra('form_builder', 'widget', array('id' => $id)); // delete form $db->delete('forms', 'id = ?', $id); }