function GetNation($nationId)
 {
     $sql = "select * from t_Nation where nationId={$nationId}";
     $sqlHelper = new SqlHelper();
     $arr = $sqlHelper->execute_dql2($sql);
     $sqlHelper->close_connect();
     // 二次封装,$arr=>Nation对象实例
     $nation = new Nation();
     if (count($arr) > 0) {
         $nation->setNationId($arr[0]['nationId']);
         $nation->setNationName($arr[0]['nationName']);
     }
     return $nation;
 }
Example #2
0
<?php 
require_once '../phpbean/Nation.class.php';
require_once '../service/NationService.class.php';
//创建了NationService实例
$nationService = new NationService();
//根据action参数决定用户要执行什么样的操作
if (!empty($_REQUEST['action'])) {
    //接收action值
    $action = $_REQUEST['action'];
    if ($action == "add") {
        //说明用户希望执行添加民族信息信息
        $nation = new Nation();
        $array_nation = $_POST["nation"];
        $nation->setNationId($array_nation['nationId']);
        $nation->setNationName($array_nation['nationName']);
        //完成添加->数据库
        $res = $nationService->AddNation($nation);
        if ($res == 1) {
            header("Location: /ok.php");
            exit;
        } else {
            //失败
            header("Location: /error.php");
            exit;
        }
    } else {
        if ($action == "query") {
            //查询民族信息信息
            require_once '../service/NationService.class.php';
            require_once '../service/FenyePage.class.php';
            //获取查询参数