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


PHP tools::connectDatabase方法代码示例

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


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

示例1: selectTrain

function selectTrain()
{
    $conn = tools::connectDatabase();
    $data = array();
    $ID = array();
    $employeeCount = array();
    $result = mysqli_query($conn, "SELECT * FROM Training");
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
        array_push($ID, $row[0]);
    }
    for ($x = 0; $x < count($ID); $x++) {
        $newID = $ID[$x];
        $employeeCount[$newID] = 0;
    }
    $newResult = mysqli_query($conn, "SELECT * FROM EmployeeTraining");
    while ($newRow = mysqli_fetch_array($newResult)) {
        for ($i = 0; $i < count($ID); $i++) {
            if ($ID[$i] == $newRow['TrainingID']) {
                $newID = $ID[$i];
                $employeeCount[$newID]++;
            }
        }
    }
    for ($z = 0; $z < count($data); $z++) {
        $tempID = $data[$z]['TrainingID'];
        $data[$z]['count'] = $employeeCount[$tempID];
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:30,代码来源:selectTrain.php

示例2: selectAuthority

function selectAuthority($authority)
{
    $conn = tools::connectDatabase();
    $allData = array();
    $employeeID = array();
    $result = mysqli_query($conn, "SELECT RoleID,RoleName FROM Roles WHERE {$authority}='1' ");
    while ($row = mysqli_fetch_array($result)) {
        array_push($allData, array('roleID' => $row['RoleID'], 'roleName' => $row['RoleName']));
    }
    for ($i = 0; $i < count($allData); $i++) {
        $roleID = $allData[$i]["roleID"];
        $result = mysqli_query($conn, "SELECT EmployeeID FROM UserRole WHERE RoleID='{$roleID}'");
        while ($row = mysqli_fetch_array($result)) {
            array_push($employeeID, $row['EmployeeID']);
        }
    }
    $employee = array();
    for ($i = 0; $i < count($employeeID); $i++) {
        $id = $employeeID[$i];
        $result = mysqli_query($conn, "SELECT EmployeeID,EmployeeName,DepartmentID,Title From Employees WHERE EmployeeID='{$id}'");
        while ($row = mysqli_fetch_array($result)) {
            array_push($employee, $row);
        }
    }
    array_push($allData, $employee);
    echo json_encode($allData);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:27,代码来源:getSelectAuthority.php

示例3: addRole

function addRole($roleName, $roleAuthority)
{
    $conn = tools::connectDatabase();
    $roleID = tools::getMaxRoleID() + 1;
    mysqli_query($conn, "INSERT INTO Roles(RoleID,RoleName,Auth_Authority,Auth_Info,Auth_Job,Auth_Attendance,Auth_Training,Auth_Evaluation,Auth_RP,Auth_Role,Auth_Encrypt) VALUES ('{$roleID}','{$roleName}','{$roleAuthority['0']}','{$roleAuthority['1']}','{$roleAuthority['2']}','{$roleAuthority['3']}','{$roleAuthority['4']}','{$roleAuthority['5']}','{$roleAuthority['6']}','{$roleAuthority['7']}','{$roleAuthority['8']}')");
    echo "success";
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:7,代码来源:addRole.php

示例4: getEmployeeInformation

function getEmployeeInformation($userID)
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT * FROM Employees WHERE EmployeeID='{$userID}'");
    while ($row = mysqli_fetch_array($result)) {
        echo json_encode($row);
    }
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:8,代码来源:getEmployeeInformation.php

示例5: getEditReward

function getEditReward()
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT * FROM RewardsAndPunishments");
    $data = array();
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:getEditReward.php

示例6: getModifyEmployee

/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2015/11/17
 * Time: 11:57
 */
function getModifyEmployee()
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT EmployeeID,EmployeeName From Employees");
    $data = array();
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:16,代码来源:getModifyEmployee.php

示例7: getEditEvaluation

function getEditEvaluation()
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT * FROM EvaluationProjects");
    $data = array();
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:getEditEvaluation.php

示例8: editTrain

function editTrain($trainingID, $startDate, $endDate, $trainType, $trainDescription)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "UPDATE Training SET BeginDate='{$startDate}',EndDate='{$endDate}',TrainingType='{$trainType}',Description='{$trainDescription}' WHERE TrainingID='{$trainingID}' ");
    } catch (Exception $e) {
        $e->getMessage();
    }
    echo "success";
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:editTrain.php

示例9: checkModifyEmployee

function checkModifyEmployee($userID)
{
    $conn = tools::connectDatabase();
    $data = array();
    $result = mysqli_query($conn, "SELECT * FROM Employees WHERE EmployeeID='{$userID}' ");
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:checkModifyEmployee.php

示例10: setDeleteEmployee

function setDeleteEmployee($userID)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "DELETE FROM Employees WHERE EmployeeID={$userID}");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:setDeleteEmployee.php

示例11: getSelectRole

function getSelectRole()
{
    $conn = tools::connectDatabase();
    $data = array();
    $result = mysqli_query($conn, "SELECT RoleID,RoleName FROM Roles");
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:getSelectRole.php

示例12: addEvaluation

function addEvaluation($ID, $name)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "INSERT INTO EvaluationProjects(RP_ID,ProjectName) VALUES({$ID},{$name})");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:addEvaluation.php

示例13: selectEmployee

function selectEmployee($sql)
{
    $conn = tools::connectDatabase();
    $data = array();
    $result = mysqli_query($conn, $sql);
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:selectEmployee.php

示例14: setModifyEmployee

function setModifyEmployee($userID, $employeeName, $sex, $phone, $birthDay, $degreeID, $departmentID, $title, $salary, $employeeTypeID, $hireDate)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "UPDATE Employees SET EmployeeName='{$employeeName}',SEX='{$sex}',Phone='{$phone}',BirthDay='{$birthDay}',DegreeID='{$degreeID}',DepartmentID='{$departmentID}',Title='{$title}',Salary='{$salary}',EmployeeTypeID='{$employeeTypeID}',HireDate='{$hireDate}' WHERE EmployeeID='{$userID}' ");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:10,代码来源:setModifyEmployee.php

示例15: addEmployee

function addEmployee($name, $sex, $phone, $birthDay, $degreeID, $departmentID, $title, $salary, $employeeTypeID, $hireDate)
{
    $conn = tools::connectDatabase();
    $ID = tools::getMaxEmployeeID() + 1;
    try {
        mysqli_query($conn, "INSERT INTO Employees(EmployeeID,EmployeeName,Sex,BirthDay,Phone,DegreeID,HireDate,EmployeeTypeID,DepartmentID,Title,Salary,ManagerID) VALUES ('{$ID}','{$name}','{$sex}','{$birthDay}','{$phone}','{$degreeID}','{$hireDate}','{$employeeTypeID}','{$departmentID}','{$title}','{$salary}','53130301'); ");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
开发者ID:anymost,项目名称:EmployeeManager,代码行数:11,代码来源:addEmployee.php


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