function loadEmployee($id) { // name $request = "SELECT * FROM employee WHERE id = {$id}"; $result = mysql_query($request); $row = mysql_fetch_object($result); $name = $row->name; $address = $row->address; $salary = $row->salary; $did = $row->did; $departments = array(); $request = "SELECT * FROM department"; $result = mysql_query($request); while ($row = mysql_fetch_object($result)) { $department["id"] = $row->id; $department["name"] = $row->name; if ($row->id == $did) { $department["parent"] = true; } else { $department["parent"] = false; } $departments[] = $department; } // create employee object $employee = new Employee(); $employee->setId($id); $employee->setName($name); $employee->setAddress($address); $employee->setSalary($salary); $employee->setDepartments($departments); // return employee object return $employee; }
public function constructReturnArr($res) { $arr = array(); $i = 0; while ($row = mysql_fetch_assoc($res)) { $emp = new Employee(); $emp->setName($row['name']); $emp->setCode($row['code']); $emp->setSalary($row['salary']); $emp->setGrade($row['grade']); $arr[$i] = $emp; $i++; } $this->getConnection()->releaseRes($res); return $arr; }
function loadEmployee($jsonObject) { $id = $jsonObject->id; // name $request = "SELECT * FROM employee WHERE id = {$id}"; $result = mysql_query($request); $row = mysql_fetch_object($result); $name = $row->name; $address = $row->address; $salary = $row->salary; // create department object $employee = new Employee(); $employee->setName($name); $employee->setAddress($address); $employee->setSalary($salary); // return department object return $employee; }
function loadEmployees($cid, $id) { // employees $employees = array(); $request = "SELECT * FROM employee WHERE did = {$id}"; $result = mysql_query($request); $count = mysql_num_rows($result); while ($row = mysql_fetch_object($result)) { $maximumSalary = getMaximumSalaryForEmployee($row->did, $row->manager); $employee = new Employee(); if ($row->salary > $maximumSalary) { $employee->setInconsistent(true); $employee->setMessage("Salary > {$maximumSalary}"); } $employee->setId($row->id); $employee->setName($row->name); $employee->setManager($row->manager); $employees[] = $employee; } return $employees; }
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Employees</title> </head> <body> <h3>Employees</h3> <?php include './Employee.php'; include './Manager.php'; $emp1 = new Employee(); $emp1->setName("Raynald"); echo "{$emp1->getName()}"; // $emp1->name = "Pancho"; // Causes error $manager = new Manager(); $manager->setName('raynaldmo'); echo "{$manager->getName()}"; ?> </body> </html>
} function setPhone($phone) { $this->phone = $phone; } function getPhone() { return $this->phone; } function printPersonInfo() { echo "<hr><b>Employee Info</b><br>"; echo $this->name . "<br>\n"; echo $this->address . "<br>\n"; echo $this->phone . "<br>\n"; } } // Create objects of the class $Heidi = new Employee(); $Heidi->setName("Heidi Clum"); $Heidi->setAddress("1234 Somewhere Blvd "); $Heidi->setPhone("123-456-7890"); echo $Heidi->getName() . "<br>\n"; echo $Heidi->getAddress() . "<br>\n"; echo $Heidi->getPhone() . "<br>\n"; $Brad = new Employee(); $Brad->setName("Brad Bit"); $Brad->setAddress("4321 Sunset Blvd "); $Brad->setPhone("987-654-3210"); $Heidi->printPersonInfo(); $Brad->printPersonInfo();
{ public $name; public $age; public $job; public $salary; public function __construct() { $this->name = "名無しさん"; $this->age = 0; $this->job = "研修員"; $this->salary = 300; } public function work() { echo '働いている!'; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; } } $saji = new Employee(); echo $saji->getName() . "<BR>"; //名無しさん $saji->setName("佐治"); echo $saji->getName() . "<BR>"; //佐治
{ $this->name = $name; } /** * @return string */ public function getMedicalCondition() { return $this->medicalCondition; } /** * @param string $medicalCondition */ public function setMedicalCondition($medicalCondition) { $this->medicalCondition = $medicalCondition; } // public function __construct($name, $medicalCondition){ // $this->name = $name; // $this->medicalCondition = $medicalCondition; // } public function createBadge() { return 'EmployeeBadge: ' . $this->getName() . ' Has the condition: ' . $this->getMedicalCondition(); } } $Adult = new Employee(); $Adult->setMedicalCondition('The Shakes'); $Adult->setName('John Doe'); echo $Adult->createBadge(); echo "\n\n";
<?php class Test { public $name; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } class Employee extends Test { public function __toString() { echo $this->name; } } $me1 = new Employee(); $me1->setName('Joshua'); echo $me1->getName();
public function executeAddStaff(sfWebRequest $request) { if ($request->isMethod('Post')) { /*Varialbes for Redirecting $user_name = $this->getRequestParameter('user_name'); $password = $this->getRequestParameter('password'); if (strlen($password) != 0) { $password = md5($password); } else $password = '';*/ // Setting Department from Selected Designation $a = new Criteria(); $a->add(DesignationPeer::ID, $this->getRequestParameter('designation_id')); $designation_record = DesignationPeer::DoSelectOne($a); $department_id = $designation_record->getDepartmentId(); // Checking if Entered Username already exist /*if($user_name != NULL) { $c = new Criteria ( ); $c->add(UserPeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL ); $c->add(UserPeer::USER, $user_name); $check_username = UserPeer::doSelectOne($c); if ($check_username) { $this->getUser ()->setFlash ( 'ERROR_MESSAGE', 'Username Already exist. Please Choose Different Username.' ); $this->redirect ('Register/add'); } }*/ $employee = new Employee(); $employee->setRoleId($this->getRequestParameter('role_id')); $employee->setName($this->getRequestParameter('name')); $employee->setCnic($this->getRequestParameter('cnic')); $employee->setDob($this->getRequestParameter('dob')); $employee->setGender($this->getRequestParameter('gender[0]')); $employee->setContactCell($this->getRequestParameter('contact_cell')); $employee->setContactRes($this->getRequestParameter('contact_res')); $employee->setContactOff($this->getRequestParameter('contact_off')); $employee->setEmergencyContact($this->getRequestParameter('emergency_contact')); $employee->setMailAddress($this->getRequestParameter('mail_address')); $employee->setDesignationId($this->getRequestParameter('designation_id')); $employee->setDepartmentId($department_id); //$employee->setRoleId(2); $employee->setEmploymentDate($this->getRequestParameter('employment_date')); $employee->setLocalResident($this->getRequestParameter('local[0]')); $employee->setQualification($this->getRequestParameter('qualification')); $employee->setEmpCategory('staff'); $employee->setStatus(Constant::RECORD_STATUS_ACTIVE); $employee->save(); $this->getUser()->setFlash('SUCCESS_MESSAGE', Constant::REGISTRATION_ACCOUNT_APPROVAL); $this->redirect('Employee/list'); /*if($user_name != NULL) { $user = new User(); $user->setEmployeeId($employee_id); $user->setUser($user_name); $user->setPassword($password); $user->setStatus(Constant::RECORD_STATUS_ACTIVE); $user->save(); // TODO: Default Rights here }// END if $this->getUser ()->setFlash ( 'SUCCESS_MESSAGE', Constant::REGISTRATION_ACCOUNT_APPROVAL ); $this->redirect('Register/list'); */ } // end IF }
private $first_name; private $last_name; private $age; private $job; private $salary; public function __construct() { $this->last_name = "名無し"; $this->first_name = "さん"; $this->age = 0; $this->job = "研修員"; $this->salary = 300; } public function work() { echo '働いている!'; } public function getName() { return $this->last_name . " " . $this->first_name; } public function setName($last_name, $first_name) { $this->last_name = $last_name; $this->first_name = $first_name; } } $saji = new Employee(); $saji->setName("佐治", "和弘"); echo $saji->getName(); //佐治 和弘
<?php // load all classes we need require 'NameInterface.php'; require 'AbstractAge.php'; require 'Person.php'; require 'Employee.php'; require 'Animal.php'; require 'Application.php'; // thanks to the abstract class, Person has setAge method enforced $person = new Person(); $person->setAge(10); $person->setName("Gary Tong"); // thanks to inheritance, Employee has the Person methods available $employee = new Employee(); $employee->setAge(30); $employee->setName("Gary Tong"); // thanks to an interface, Animal has the setName method enforced $animal = new Animal(); $animal->setName("Snofu Tong"); $app = new Application($person); echo $app::VERSION; // get the class constant $app->run();
$newTchr2->store(); $newTchr2->displayInfo(); $newTchr3 = new Teacher(); $newTchr3->setName('Ivan'); $newTchr3->setSurname('Ivanov'); $newTchr3->setFamilyName('Todorov'); $newTchr3->setPersonalId(789012134); $newTchr3->setItem('Math'); $newTchr3->store(); $newTchr3->displayInfo(); $newEmpl1 = new Employee(); $newEmpl1->setName('Milena'); $newEmpl1->setSurname('Todorova'); $newEmpl1->setFamilyName('Todorova'); $newEmpl1->setPersonalId(233456789); $newEmpl1->setPosition('Librarist'); $newEmpl1->store(); $newEmpl1->displayInfo(); $newEmpl2 = new Employee(); $newEmpl2->setName('Petia'); $newEmpl2->setSurname('Ivanova'); $newEmpl2->setFamilyName('Todorova'); $newEmpl2->setPersonalId(890412345); $newEmpl2->setPosition('Cleaner'); $newEmpl2->store(); $newEmpl2->setPosition('Accountant'); $newEmpl2->store(); $newEmpl2->displayInfo(); echo "Total students: " . Student::$addNewStudent . "<br/>"; echo "Total lectors: " . Teacher::$addNewTeacher . "<br/>"; echo "Total employees: " . Employee::$addNewEmployee . "<br/><hr/>";