* 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 = 2; // try and select a specific record based on the ID given if ($employee->select($id)) { // print out, before record update echo "Before update: " . $employee->id . ", " . $employee->first_name . ", " . $employee->last_name . ", " . $employee->job_id . "\n"; $new_job_id = 1; $record_changes = array('first_name' => 'Larry', 'last_name' => 'Fine', 'job_id' => $new_job_id); // try and update the record if ($employee->update($record_changes)) { // re-select record (get the update record) $employee->select($id); // print out, after record update echo "After update: " . $employee->id . ", " . $employee->first_name . ", " . $employee->last_name . ", " . $employee->job_id . "\n"; } else { echo "Unable to update the record.\n"; } } else { echo "Unable to find the record.\n"; } // -EOF-
$landline = $_POST['landline']; $mobile = $_POST['mobile']; $homeline = $_POST['homeline']; $address = $_POST['address']; $birth = $_POST['birth']; $twitter = $_POST['twitter']; $facebook = $_POST['facebook']; $email = $_POST['email']; $password = isset($_POST['password']) ? md5($_POST['password']) : NULL; $type = isset($_POST['type']) ? $_POST['type'] : 2; $employee = new employee($name, $lastname, $landline, $mobile, $homeline, $address, $birth, $twitter, $facebook, $email, $password, $type, $id); /*Transaction status*/ $status = 'ok'; if (isset($_POST['id_hidden'])) { //Update if (!$employee->update($connection)) { //Error $error = $connection->lastError(); if ($error['errno'] == 1062) { //UQ value error $status = "repeat"; } else { $status = "Error {$error['errno']}: {$error['error']}"; } } } else { //Insert if (!$employee->insert($connection)) { //Error $error = $connection->lastError(); if ($error['errno'] == 1062) {