Exemplo n.º 1
0
 public function getSave()
 {
     $id = Input::get('id');
     if ($id) {
         $employee = employee::find($id);
         $employee->full_name = Input::get('name');
         $employee->position = Input::get('position');
         $employee->gender = Input::get('gender');
         $employee->phone = Input::get('phone');
         $employee->email = Input::get('email');
         $employee->address = Input::get('address');
         $employee->city_id = Input::get('city_id');
         $employee->save();
         Session::flash('message', 'The records are updated successfully');
     } else {
         $employee = new employee();
         $employee->full_name = Input::get('name');
         $employee->position = Input::get('position');
         $employee->gender = Input::get('gender');
         $employee->phone = Input::get('phone');
         $employee->email = Input::get('email');
         $employee->address = Input::get('address');
         $employee->city_id = Input::get('city_id');
         $employee->save();
         Session::flash('message', 'The records are inserted successfully');
     }
     return Redirect::to('employee');
 }
Exemplo n.º 2
0
<?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();
$job_id = 1;
// Software Engineer (from `job` table)
$privilege = 'Administrator';
$record = array('first_name' => 'Curly', 'last_name' => 'Howard', 'phone' => '888-9999', 'job_id' => $job_id, 'access' => $privilege, 'created_on' => date("Y-m-d H:i:s", time()));
// insert/save new record
$id = $employee->save($record);
// print record ID
echo "Record ID: " . $id . "\n";
// -EOF-
Exemplo n.º 3
0
 public function save($id = 0, $login = '', $fullname = '', $profiles_id = 0)
 {
     // Check if this operation is requested to the default object
     if ($id != 0) {
         // Create, fill and save the employee
         $employee = new employee($id);
         $employee->fill($id, $login, $fullname, $profiles_id);
         $employee->save();
     } else {
         $database = $_SESSION['database'];
         // Insert a new entry if one does not exist or update the existing one
         if (!$this->id_exists($this->id)) {
             // The entry does not exist
             $database->query("insert into " . TABLE_EMPLOYEES . " (employees_id, employees_login, employees_fullname, profiles_id) values ('" . $this->id . "', '" . $this->login . "', '" . $this->fullname . "', '" . $this->profile->id . "')");
         } else {
             // The entry exists, update the contents
             $activity_query = $database->query("update " . TABLE_EMPLOYEES . " set employees_id='" . $this->id . "', employees_login='******', employees_fullname='" . $this->fullname . "', profiles_id='" . $this->profile->id . "' where employees_id = '" . (int) $this->id . "'");
         }
     }
 }