当前位置: 首页>>代码示例>>PHP>>正文


PHP Employee::fromArray方法代码示例

本文整理汇总了PHP中Employee::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::fromArray方法的具体用法?PHP Employee::fromArray怎么用?PHP Employee::fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Employee的用法示例。


在下文中一共展示了Employee::fromArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute


//.........这里部分代码省略.........
     // SERVICES
     $query = 'SELECT * FROM %s';
     $query = sprintf($query, 'tbl_services');
     $statement = $source->prepare($query);
     $statement->execute();
     $services = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         ServicePeer::doDeleteAll($connection);
         foreach ($services as $service) {
             $this->logSection('service', 'reading service ' . $service['service_title']);
             $s1 = new Service();
             $s1->setName($service['service_title']);
             $s1->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // EMPLOYEES
     $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.emp_job_title = %s.job_id)';
     $query = sprintf($query, 'tbl_employee', 'tbl_job', 'tbl_employee', 'tbl_job');
     $statement = $source->prepare($query);
     $statement->execute();
     $employees = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         EmployeePeer::doDeleteAll($connection);
         foreach ($employees as $employee) {
             $this->logSection('employee', 'reading employee ' . $employee['emp_id']);
             $emp = new Employee();
             $emp_fields = array('clearance' => $employee['emp_scr_clearance'], 'first_name' => $employee['emp_fn'], 'middle' => $employee['emp_mi'], 'last_name' => $employee['emp_ln'], 'address' => $employee['emp_address'], 'address_2' => $employee['emp_address2'], 'city' => $employee['emp_city'], 'state' => $employee['emp_state'], 'zip' => $employee['emp_zip'], 'home_phone' => $employee['emp_phone'], 'cell_phone' => $employee['emp_cell'], 'company_email' => $employee['emp_email'], 'personal_email' => $employee['emp_p_email'], 'license_number' => $employee['emp_license_number'], 'license_expiration' => $employee['emp_license_exp'], 'dob' => $employee['emp_dob'], 'doh' => $employee['emp_hire_date'], 'dof' => $employee['emp_end_date'], 'ssn' => $employee['emp_ssn'], 'health_insurance' => $employee['emp_health'], 'retirement_plan' => $employee['emp_401k'], 'suplimental_health' => $employee['emp_health_sup'], 'health_type' => $employee['emp_health_type'], 'tb_date' => $employee['emp_tb'], 'osha_date' => $employee['emp_osha'], 'cpr_date' => $employee['emp_cpr'], 'finger_prints' => $employee['emp_fp'], 'finger_print_notes' => $employee['emp_fp_n'], 'notes' => $employee['emp_notes']);
             $emp->fromArray($emp_fields, BasePeer::TYPE_FIELDNAME);
             // find the job - check for errors
             $emp->setJob(JobPeer::getByName($employee['job_title']));
             // if physical has a date then create a new physical object for employee
             if ($employee['emp_physical']) {
                 $this->logSection('physical', 'employee ' . $employee['emp_fn'] . ' had a physical on ' . $employee['emp_physical']);
                 $ph1 = new Physical();
                 $ph1->setEmployee($emp);
                 $ph1->setDateGiven($employee['emp_physical']);
                 $ph1->save($connection);
             }
             $emp->save($connection);
         }
         $connection->commit();
     } catch (PropelException $e) {
         $connection->rollBack();
         throw $e;
     }
     // read in and create client objects - linking to employee
     // CLIENTS
     $query = 'SELECT * FROM %s LEFT JOIN (%s) ON (%s.client_district = %s.district_id)';
     $query = sprintf($query, 'tbl_client', 'tbl_district', 'tbl_client', 'tbl_district');
     $statement = $source->prepare($query);
     $statement->execute();
     $clients = $statement->fetchAll();
     $connection->beginTransaction();
     try {
         ClientPeer::doDeleteAll($connection);
         foreach ($clients as $client) {
             $this->logSection('client', 'reading client ' . $client['client_ln']);
             $cl = new Client();
             $client_fields = array('first_name' => $client['client_fn'], 'last_name' => $client['client_ln'], 'dob' => $client['client_dob'], 'parent_first' => $client['client_parent_fn'], 'parent_last' => $client['client_parent_ln'], 'address' => $client['client_address'], 'address_2' => $client['client_address2'], 'city' => $client['client_city'], 'state' => $client['client_state'], 'zip' => $client['client_zip'], 'home_phone' => $client['home_phone'], 'work_phone' => $client['work_phone'], 'cell_phone' => $client['cell_phone'], 'blue_card' => $client['blue_card'], 'physical_exp' => $client['physical_exp_date'], 'immunizations' => $client['immunizations'], 'waiting_list' => $client['waiting_list']);
             // county
开发者ID:anvaya,项目名称:nckids,代码行数:67,代码来源:importTask.class.php

示例2: testFilterEmployeeListBySubUnit

 /**
  * Testing filterEmployeeListBySubUnit
  */
 public function testFilterEmployeeListBySubUnit()
 {
     $subUnitId = 12;
     $employees = array();
     foreach ($this->testCase['Employee'] as $values) {
         $employee = new Employee();
         $employee->fromArray($values);
         $employees[] = $employee;
     }
     $employees[0]->setWorkStation($subUnitId);
     // Search by specific sub unit
     $result = $this->employeeService->filterEmployeeListBySubUnit($employees, $subUnitId);
     $this->assertTrue(is_array($result));
     $this->assertEquals(1, count($result));
     $this->assertEquals($employees[0], $result[0]);
     // Search by Root - Should return all employees in list
     $result = $this->employeeService->filterEmployeeListBySubUnit($employees, 1);
     $this->assertEquals($employees, $result);
     // Empty subunit Id should be the same as root
     $result = $this->employeeService->filterEmployeeListBySubUnit($employees, NULL);
     $this->assertEquals($employees, $result);
     // If no employee list passed, will get all employees from dao adn filter
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getEmployeeList')->will($this->returnValue($employees));
     $this->employeeService->setEmployeeDao($mockDao);
     $result = $this->employeeService->filterEmployeeListBySubUnit(NULL, $subUnitId);
     $this->assertTrue(is_array($result));
     $this->assertEquals(1, count($result));
     $this->assertEquals($employees[0], $result[0]);
     // Dao Exception
     $mockDao = $this->getMock('EmployeeDao');
     $mockDao->expects($this->once())->method('getEmployeeList')->will($this->throwException(new DaoException()));
     $this->employeeService->setEmployeeDao($mockDao);
     try {
         $result = $this->employeeService->filterEmployeeListBySubUnit(NULL, $subUnitId);
         $this->fail("Exception expected");
     } catch (Exception $e) {
         $this->assertTrue($e instanceof PIMServiceException);
     }
 }
开发者ID:rabbitdigital,项目名称:HRM,代码行数:43,代码来源:EmployeeServiceTest.php

示例3: getSampleDoctrineRecord

 /**
  * @return Doctrine_Record
  */
 protected function getSampleDoctrineRecord()
 {
     $record = new Employee();
     $record->fromArray(array('firstName' => 'John', 'lastName' => 'Smith'));
     return $record;
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:9,代码来源:WSUtilityDaoTest.php


注:本文中的Employee::fromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。