/** * Edit an existing DVD. * @param $data - Array with appropriately named key/value pairs (release_year, director, ratings, genre, title) * @return 1 on success 0 otherwise. */ function edit_dvd($data) { $safe_values = array(); foreach ($data as $key => $value) { $safe_values[$key] = mysql_escape_string($value); } $sql = "UPDATE dvd SET release_year = '{$safe_values['release_year']}', " . "director = '{$safe_values['director']}'," . "rating = '{$safe_values['rating']}', " . "genre = '{$safe_values['genre']}' WHERE title = '{$safe_values['title']}'"; execute_update($sql); return 1; }
border: 1px dotted #999; } </style> </head> <body> <h1>AuthZ2 Migration</h1> <?php if (!isset($updater)) { $updater = new AuthZ2Updater(); } print "\n\t<p>" . $updater->getDescription() . "</p>"; if (isset($_REQUEST['db_type']) && isset($_REQUEST['db_host']) && isset($_REQUEST['db_name']) && isset($_REQUEST['db_user']) && isset($_REQUEST['db_pass'])) { print "\n\t\t<h2>" . _("Results") . "</h2>"; print "\n\t<div class='results'>"; try { execute_update($types); } catch (Exception $e) { HarmoniErrorHandler::handleException($e); } print "\n\t</div>"; } print "\n\t<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>"; /********************************************************* * Database Type *********************************************************/ print "\n\t\t<div class='db_type'>"; print "\n\t\t\t<h3>" . _("Database Type:") . "</h3>"; foreach ($types as $type => $desc) { print "\n\t\t\t<div>"; print "\n\t\t\t\t<input type='radio' name='db_type' value='" . $type . "' " . (isset($_REQUEST['db_type']) && $_REQUEST['db_type'] == $type ? " checked='checked'" : "") . " />" . $desc; print "\n\t\t\t</div>";
/** * Edit an existing DVD. * @param $data - array where 0 = title, 1 = release year, 2 = director, 3 = rating, 4 = genre * @return 1 on success 0 otherwise. */ function edit_dvd($data) { global $logger; $querystring = "UPDATE dvd SET release_year = ?, director = ?, rating = ?, genre = ? WHERE title = ?"; $data_array = array($data['release_year'], $data['director'], $data['rating'], $data['genre'], $data['title']); execute_update($querystring, $data_array); $logger->info("DVD {$data['title']} updated"); return 1; }
/** * Use this to delete a Genre from the database * * <p>Deletes from the genre table based upon the value given for the genre * name.Deletion is likely to fail due to referential integrity reasons if * the genre is in use by e.g. the dvd table.</p> * * <p>If there is not an identifiable record, the deletion will silently * fail (in that nothing will be deleted, and you won't be warned.).</p> * * @exception DbException in the event of a database error - such as * the genre is referenced in the dvd table, or a syntax error takes place. * @param String $genre The name of the genre to delete (eg. Comedy). * @global Log $logger used to log / monitor. */ function delete_genre($name) { global $logger; $sql = "DELETE FROM genre WHERE genre_name = ?"; execute_update($sql, array($name)); $logger->debug("Genre {$name} deleted."); }
.results { padding: 10px; background-color: #CCC; border: 1px dotted #999; } </style> </head> <body> <h1>Database Updater</h1> <?php if (isset($_REQUEST['db_type']) && isset($_REQUEST['db_host']) && isset($_REQUEST['db_name']) && isset($_REQUEST['db_user']) && isset($_REQUEST['db_pass']) && isset($_REQUEST['function'])) { print "\n\t\t<h2>" . _("Results") . "</h2>"; print "\n\t<div class='results'>"; try { execute_update($types, $functions); } catch (Exception $e) { HarmoniErrorHandler::handleException($e); } print "\n\t</div>"; } print "\n\t<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>"; /********************************************************* * Database Type *********************************************************/ print "\n\t\t<div class='db_type'>"; print "\n\t\t\t<h3>" . _("Database Type:") . "</h3>"; foreach ($types as $type => $desc) { print "\n\t\t\t<div>"; print "\n\t\t\t\t<input type='radio' name='db_type' value='" . $type . "' " . (isset($_REQUEST['db_type']) && $_REQUEST['db_type'] == $type ? " checked='checked'" : "") . " />" . $desc; print "\n\t\t\t</div>";