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


PHP Department::delete方法代码示例

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


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

示例1: delDepartment

 /**
  * Delete a department from database with the passed ID.
  */
 public static function delDepartment($departmentId)
 {
     $dept = new Department($departmentId);
     if ($dept->id == 0) {
         // Department wasn't loaded correctly
         NQ::simple('intern', INTERN_ERROR, "Error occurred while loading department from database.");
         return;
     }
     $name = $dept->getName();
     try {
         // Try to delete department.
         if (!$dept->delete()) {
             // Something bad happend. This should have been caught in the check above...
             NQ::simple('intern', INTERN_SUCCESS, "Error occurred deleting department from database.");
             return;
         }
     } catch (Exception $e) {
         NQ::simple('intern', INTERN_ERROR, $e->getMessage());
         return;
     }
     // Department deleted successfully.
     NQ::simple('intern', INTERN_SUCCESS, "Deleted department <i>{$name}</i>");
 }
开发者ID:jeffrafter,项目名称:InternshipInventory,代码行数:26,代码来源:Department.php

示例2: Department

 function test_delete()
 {
     //Arrange
     $name = "Biology";
     $address = "346 Stupid Avenue";
     $test_department = new Department($name, $address);
     $test_department->save();
     $name2 = "Chemiology";
     $address2 = "55 Bo Ct";
     $test_department2 = new Department($name2, $address2);
     $test_department2->save();
     //Act
     $test_department->delete();
     //Assert
     $result = Department::getAll();
     $this->assertEquals([$test_department2], $result);
 }
开发者ID:ashlinaronin,项目名称:back2school_fam,代码行数:17,代码来源:DepartmentTest.php


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