Oracle B25-317-01 Bedienungsanleitung Seite 58

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 94
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 57
Adding Error Recovery
5-20 Oracle Database Express Edition 2 Day Plus PHP Developer Guide Beta Draft
}
}
}
13. Edit anyco.php. Change modify_emp() to handle errors. The function becomes:
function modify_emp()
{
$newemp = $_POST;
$statement =
"UPDATE employees
SET first_name = :fnm, last_name = :lnm, email = :eml,
salary = :sal, commission_pct = :cpt
WHERE employee_id = :eid";
$conn = db_connect($err);
if (!$conn) {
handle_error('Connect Error', $err);
}
else {
$bindargs = array();
array_push($bindargs, array('EID', $newemp['empid'], -1));
array_push($bindargs, array('FNM', $newemp['firstname'], -1));
array_push($bindargs, array('LNM', $newemp['lastname'], -1));
array_push($bindargs, array('EML', $newemp['email'], -1));
array_push($bindargs, array('SAL', $newemp['salary'], -1));
array_push($bindargs, array('CPT', $newemp['commpct'], -1));
$r = db_execute_statement($conn, $statement, $err, $bindargs);
if (!$r) {
handle_error('Cannot update employee '.$newemp['empid'], $err);
}
else {
construct_employees();
}
}
}
14. Edit anyco.php. Modify delete_emp to handle errors. The function becomes:
function delete_emp()
{
if (!isset($_POST['emprec'])) { // User didn't select a record
construct_employees();
}
else {
$empid = $_POST['emprec'];
$conn = db_connect($err);
if (!$conn) {
handle_error('Connection Error', $err);
}
else {
$statement = "DELETE FROM employees WHERE employee_id = :empid";
$bindargs = array();
array_push($bindargs, array('EMPID', $empid, -1));
$r = db_execute_statement($conn, $statement, $err, $bindargs);
if (!$r) {
Seitenansicht 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 93 94

Kommentare zu diesen Handbüchern

Keine Kommentare