public static function update($id) { $params = $_POST; $attributes = array('id' => $id, 'name' => $params['name'], 'year' => $params['year'], 'city' => $params['city']); $Team = new Team($attributes); $errors = $Team->errors(); if (count($errors) != 0) { View::make('/Team/edit.html', array('errors' => $errors, 'attributes' => $attributes)); } else { $Team->update(); Redirect::to('/team/' . $Team->id, array('message' => 'Joukkuetta on muokattu onnistuneesti!')); } }
function _ops_update() { $OID = max(0, intval($_POST['OID'])); $CID = max(0, intval($_POST['CID'])); $msg = ""; loginRequireMgmt(); if (!loginCheckPermission(USER::MGMT_TEAM)) { redirect("errors/401"); } $itemName = "Team"; $urlPrefix = "mgmt_team"; $object = new Team(); if ($OID) { $object->retrieve($OID, $CID); if (!$object->exists()) { $msg = "{$itemName} not found!"; } else { transactionBegin(); $object->merge($_POST); if ($object->update()) { transactionCommit(); $msg = "{$itemName} updated!"; } else { transactionRollback(); $msg = "{$itemName} update failed"; } } } else { $object->merge($_POST); for ($retry = 0; $retry < PIN_RETRY_MAX; $retry++) { $pin = Team::generatePIN(); if (Team::getFromPin($pin) === false) { // not a duplicate $object->set('pin', $pin); transactionBegin(); if ($object->create() !== false) { transactionCommit(); $msg = "{$itemName} created!"; break; } } } if ($retry >= PIN_RETRY_MAX) { transactionRollback(); $msg = "{$itemName} Create failed"; } } redirect("{$urlPrefix}/manage", $msg); }
echo $rs["id_project"]; ?> ', '#app_pane_body'); }, 100); window.parent.boss.popup("Error ao deletar equipe."); </script> <?php } } else { $model = new Team(); $sql = array('id_team' => $pk, 'status' => '1'); $fields = array("id_project"); $rs = $model->get($sql); $rs = $rs[0]; $model->fields = array('name' => $name, 'website' => $website, 'slug' => $slug); $update = $model->update($sql); if ($update) { ?> <script> var timePopup = setTimeout(function(){ window.parent.boss.removeClass('modal_dialog', 'active'); window.parent.boss.ajax.load('/app/team/view_team/?pk=<?php echo $rs["id_project"]; ?> ', '#app_pane_body'); }, 100); window.parent.boss.popup("Sucesso ao editar equipe."); </script> <?php } else { ?>
$origteam->fetchdets(); } catch (TeamException $e) { $mess = $e->getMessage(); include 'php/wrongentry.php'; exit(0); } // Check name changes $newteam = new Team($teamname); if (!$origteam->is_same($newteam)) { checkname($newteam); $origteam->updatename($newteam); } $origteam->Description = $teamdescr; $origteam->Division = $teamdiv; $origteam->Captain = new Player($captfirst, $captlast); $origteam->update(); $Title = "Team {$origteam->display_name()} updated OK"; break; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <?php $Title = "Team update complete"; include 'php/head.php'; ?> <body> <script language="javascript" src="webfn.js"></script> <?php $showadmmenu = true; include 'php/nav.php';
<?php require_once "/etc/apache2/capstone-mysql/encrypted-config.php"; require_once "your-class-file.php"; $pdo = connectToEncryptedMySQL("/etc/apache2/data-design/dfontaine1.ini"); // now procede to PDO normally $team = new Team(null, 1, "this is from PHP"); $team->insert($pdo); $team->setTeamContent("now I change the message"); $team->update($pdo); $team->delete($pdo);