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


PHP Department::setTotal方法代码示例

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


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

示例1: loadDepartment

function loadDepartment($jsonObject)
{
    $id = $jsonObject->id;
    // name
    $request = "SELECT * FROM department WHERE id = {$id}";
    $result = mysql_query($request);
    $row = mysql_fetch_object($result);
    $name = $row->name;
    // departments
    $departments = array();
    $request = "SELECT * FROM department WHERE did = {$id}";
    $result = mysql_query($request);
    $count = mysql_num_rows($result);
    while ($row = mysql_fetch_object($result)) {
        $departments[] = $row->name;
    }
    // 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)) {
        if ($row->manager == true) {
            $manager = $row->name;
        } else {
            $employees[] = $row->name;
        }
    }
    // total
    $total = totalDepartment($id);
    // create department object
    $department = new Department();
    $department->setDepartments($departments);
    $department->setEmployees($employees);
    $department->setManager($manager);
    $department->setName($name);
    $department->setTotal($total);
    // return department object
    return $department;
}
开发者ID:nuzil,项目名称:101repo,代码行数:40,代码来源:departmentServer.php

示例2: loadDepartment

function loadDepartment($id)
{
    // name
    $request = "SELECT * FROM department WHERE id = " . $id;
    $result = mysql_query($request);
    $row = mysql_fetch_object($result);
    $name = $row->name;
    $parent = $row->did;
    // departments
    $unselectable = unselectable($id);
    $departments = array();
    $request = "SELECT * FROM department WHERE id NOT IN (" . $unselectable . ")";
    $result = mysql_query($request);
    while ($row = mysql_fetch_object($result)) {
        $department["id"] = $row->id;
        $department["name"] = $row->name;
        if ($row->id == $parent) {
            $department["parent"] = true;
        } else {
            $department["parent"] = false;
        }
        $departments[] = $department;
    }
    // employees
    $employees = array();
    $request = "SELECT * FROM employee";
    $result = mysql_query($request);
    while ($row = mysql_fetch_object($result)) {
        $employee = array();
        $employee["id"] = $row->id;
        $employee["name"] = $row->name;
        if ($row->manager == true && $row->did == $id) {
            $employee["manager"] = true;
        } else {
            $employee["manager"] = false;
        }
        $employees[] = $employee;
    }
    // total
    $total = totalDepartment($id);
    // create department object
    $department = new Department();
    $department->setId($id);
    $department->setDepartments($departments);
    $department->setEmployees($employees);
    $department->setName($name);
    $department->setTotal($total);
    // return department object
    return $department;
}
开发者ID:nuzil,项目名称:101repo,代码行数:50,代码来源:departmentServer.php


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