public function deleteOnClick($sender) { employee::delete($sender->owner->getDataItem()->employee_id); $this->employeetable->employeelist->Reload(); }
require 'path.php'; init_cobalt('Delete employee'); if (isset($_GET['employee_id'])) { $employee_id = urldecode($_GET['employee_id']); require_once 'form_data_employee.php'; } if (xsrf_guard()) { init_var($_POST['btn_cancel']); init_var($_POST['btn_delete']); require 'components/query_string_standard.php'; if ($_POST['btn_cancel']) { log_action('Pressed cancel button'); redirect("listview_employee.php?{$query_string}"); } elseif ($_POST['btn_delete']) { log_action('Pressed delete button'); require_once 'subclasses/employee.php'; $dbh_employee = new employee(); $object_name = 'dbh_employee'; require 'components/create_form_data.php'; $dbh_employee->delete($arr_form_data); redirect("listview_employee.php?{$query_string}"); } } require 'subclasses/employee_html.php'; $html = new employee_html(); $html->draw_header('Delete Employee', $message, $message_type); $html->draw_listview_referrer_info($filter_field_used, $filter_used, $page_from, $filter_sort_asc, $filter_sort_desc); $html->draw_hidden('employee_id'); $html->detail_view = TRUE; $html->draw_controls('delete'); $html->draw_footer();
<?php /** * Copyright (c) 2012 Ryan Yonzon, <*****@*****.**> * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ // Enable full-blown error reporting. http://twitter.com/rasmus/status/7448448829 error_reporting(-1); require '../ormbit.init.php'; // require and initialize ORMbit class // intantiate: /models/employee.model.php $employee = new employee(); // record ID $id = 11; // select specific record by ID $employee->select($id); // try and delete that record if ($employee->delete()) { echo "Record deleted.\n"; } else { echo "Unable to delete the record.\n"; } // -EOF-
public function delete($id = 0) { if ($id != 0) { // Create and delete employee $employee = new employee($id); $employee->delete(); } else { $database = $_SESSION['database']; $this->id = $database->prepare_input($this->id); $employee_query = $database->query("delete from " . TABLE_EMPLOYEES . " where employees_id = '" . (int) $this->id . "'"); // Reset id, otherwise one might think this employee (still) exists in db $this->id = 0; } }
<?php include 'db_connection.php'; include 'classes/employee.php'; $connection = new db_connection(); $where = stripslashes($_POST['where']); /*Transaction status*/ $status = 'ok'; if (!employee::delete($connection, $where)) { //Error $error = $connection->lastError(); $status = "Error {$error['errno']}: {$error['error']}"; } /*XML transaction result.*/ header('Content-Type: text/xml'); echo '<transaction> <status>' . $status . '</status> </transaction> '; $connection->close();