关于php:海外多语言国际婚恋相亲网站开发制作第四篇

36次阅读

共计 7192 个字符,预计需要花费 18 分钟才能阅读完成。


第一篇:https://blog.csdn.net/weixin_…

第二篇:https://segmentfault.com/a/11…

第三篇:https://segmentfault.com/a/11…

这个是国内多语言婚恋交友网站开发制作的专栏:

https://blog.csdn.net/weixin_…

如果有什么疑难能够,找我,各位,我的扣是 2360248-666

国内多语言婚恋交友网站开发制作,第四篇
粉丝局部的性能开发

浏览粉丝

public function index(){

        //echo "浏览";
        $atten = D('byattention');
        $total = $atten->where('uid='.session('user')['id'])->count();
        $page = new \Think\Page($total,9);
        $mod = $atten->order('byaid desc')->field('uid')->limit($page->firstRow,$page->listRows)->where('byattenid='.session('user')['id'])->select();

        // 定义一个空数组
        $list = array();
        // 依据 attenid 获取关注的用户详情
        foreach($mod as $k=>$v){$list[] = $v['uid'];
        }
        
        // 定义一个空数组承受查问信息
        $res = array();
        $resu = array();
        // 遍历 $list 数组
        foreach($list as $v1){
            // 执行查问
            $res[$v1] = D('user_params')->where('userid='.$v1)->field('id,gender,ageyear,marrystatus,height,cityid,monolog')->find();
            if(strlen($res[$v1]['monolog'])>27){$res[$v1]['monolog1'] = mb_substr($res[$v1]['monolog'],0,12,"utf-8")."...";
            }
            $resu[$v1] = D('user')->where('id='.$v1)->field('username,avatar,id')->find();}

        // 依据出世年算出年龄
        $sex = array('1'=>'未婚','2'=>'已婚','3'=>'离异');
        foreach($res as $k=>$v){$res[$k]['ageyear'] = date('Y',time())-$res[$k]['ageyear'];
            $res[$k]['marrystatus'] = $sex[$res[$k]['marrystatus']];
            $city[$k] = D('district')->where('id='.$res[$k]['cityid'])->field('name,upid')->find();
            $city1[$k] = D('district')->where('id='.$city[$k]['upid'])->field('name')->find();}
        $users = array();
        foreach($resu as $k=>$v){$users[$k] = $v;
            if($users[$k]['avatar'] == null){if($res[$k]['gender'] == 1){$users[$k]['avatar'] = 'male.gif';
                }else{$users[$k]['avatar'] = 'female.gif';
                }
            }
        }

        $this->assign('city1',$city1);
        $this->assign('city',$city);
        $this->assign('users',$users);
        $this->assign('res',$res);
        $this->assign('pageInfo',$page->show());
        $this->display('byattention');        
    }

}

?>

查问看过的用户信息

public function index(){

        $atten = D('see');
        $total = $atten->where('seeid='.session('user')['id'])->count();
        $page = new \Think\Page($total,10);
        $mod = $atten->order('id desc')->field('uid')->limit($page->firstRow,$page->listRows)->where('seeid='.session('user')['id'])->select();
        
        // 定义一个空数组
        $list = array();
        
        // 依据 attenid 获取关注的用户详情
        foreach($mod as $k=>$v){$list[] = $v['uid'];
        }
        
        // 定义一个空数组承受查问信息
        $res = array();
        $resu = array();
        // 遍历 $list 数组
        foreach($list as $v1){
            // 执行查问
            $res[$v1] = D('user_params')->where('userid='.$v1)->field('id,gender,ageyear,marrystatus,height,cityid,monolog,education,salary')->find();
            if(strlen($res[$v1]['monolog'])>27){$res[$v1]['monolog1'] = substr($res[$v1]['monolog'],0,27)."...";
            }
            $resu[$v1] = D('user')->where('id='.$v1)->field('username,avatar,id')->find();}
        
        // 依据出世年算出年龄
        $sex = array('1'=>'未婚','2'=>'已婚','3'=>'离异');
        $education=array(1=>"中专以下学历",2=>"中专",3=>"大专",4=>"本科",5=>"硕士",6=>"博士",7=>"博士后");
        $salary = array(1=>'低于 2000 元',2=>'2000~5000 元',3=>'5000~10000 元',4=>'10000~20000 元',5=>'高于 20000 元');
        foreach($res as $k=>$v){$res[$k]['attentionid'] = $atten->field('id')->where('attenid='.$k)->find()['id'];
            $res[$k]['ageyear'] = date('Y',time())-$res[$k]['ageyear'];
            $res[$k]['marrystatus'] = $sex[$res[$k]['marrystatus']];
            if(empty($res[$k]['education'])){$res[$k]['education'] = "未填写";
            }else{$res[$k]['education'] = $education[$res[$k]['education']];
            }
            if(empty($res[$k]['salary'])){$res[$k]['salary'] = "未填写";
            }else{$res[$k]['salary'] = $salary[$res[$k]['salary']];
            }
            
            $city[$k] = D('district')->where('id='.$res[$k]['cityid'])->field('name,upid')->find();
            $city1[$k] = D('district')->where('id='.$city[$k]['upid'])->field('name')->find();}
    
        $users = array();
        foreach($resu as $k=>$v){$users[$k] = $v;
            if($users[$k]['avatar'] == null){if($res[$k]['gender'] == 1){$users[$k]['avatar'] = 'male.gif';
                }else{$users[$k]['avatar'] = 'female.gif';
                }
            }
        }
        $this->assign('city1',$city1);
        $this->assign('city',$city);
        $this->assign('users',$users);
        $this->assign('res',$res);
        $this->assign('pageInfo',$page->show());
        $this->assign('totalPages',$page->totalPages);
        $this->display('index');
    }

}

?>

浏览择友选项办法

public function index(){

    $userid = session("user")['id'];
    $sel = M("choose")->where("userid=".$userid)->order("id desc")->find();
    // 反串行化返回模板
    $weight = unserialize($sel['weight']);
    $education = unserialize($sel['education']);
    $star = unserialize($sel['star']);
    $age = unserialize($sel['age']);
    $hismarriage = unserialize($sel['hismarriage']);
    $type = unserialize($sel['type']);
    $area = unserialize($sel['area']);

    $this->assign("weight",$weight);
    $this->assign("age",$age);
    $this->assign("hismarriage",$hismarriage);
    $this->assign("type",$type);;
    $this->assign("education",$education);
    $this->assign("areaa",json_encode($area[0]));

    $this->assign("sex",$sel['sex']);
    $this->assign("star",$star);
    $this->assign("ishead",$sel['ishead']);

    $mod = M("district");
    $list = $mod->where("id=".$area[1])->find();

    $this->assign("area",$list);
    $this->display("index");
}

// 设置择友条件办法
public function update(){
    // 串行化数组值
    $userid = session("user")['id'];
    $age = serialize($_POST['age']);
    $weight = serialize($_POST['weight']);
    $star = serialize($_POST['star']);
    $education = serialize($_POST['education']);
    $area = serialize($_POST['area']);
    $hismarriage = serialize($_POST['hismarriage']);
    $type = serialize($_POST['type']);

    $data['userid'] = $userid;
    $data['sex'] = $_POST['sex'];
    $data['age'] = $age;
    $data['weight'] = $weight;
    $data['hismarriage'] = $hismarriage;
    $data['type'] = $type;
    $data['education'] = $education;
    $data['area'] = $area;
    $data['star'] = $star;
    $data['ishead'] = $_POST['ishead'];

    // 封装信息
    $cho = M('choose')->where("userid=".$userid)->field('userid')->find();
    
     if(empty($cho)){$s = M('choose')->add($data);
        $this->assign("sysCall","增加胜利!");
        $this->assign("sysUrl",$_SERVER['HTTP_REFERER']);
        $this->display("Login/loginInfo");
    }else{$d = M('choose')->where("userid=".$userid)->save($data);
        $this->assign("sysCall","批改胜利!");
        $this->assign("sysUrl",$_SERVER['HTTP_REFERER']);
        $this->display("Login/loginInfo");
    }
}


// 加载城市信息办法
public function loaddist($upid=0){$mod = M("district");
    $list = $mod->where("upid=".$upid)->select();
    echo json_encode($list);
    exit;
}    

}

户核心拿出用户的一些信息

$user = D(‘User’)->field()->find(session(‘user’)[‘id’]);

                                $this->userother=M('User_params')->where('userid='.session('user')['id'])->find();
                                $this->userother1=M('Contact_information')->where('userid='.session('user')['id'])->find();
                             //   dump($this->userother1);
                             //   dump($this->userother);
    //$webconfig = M('Webconfig')->index('code')->select();
    //var_dump($webconfig);exit;
    $this->assign('user', $user);

     // 函件音讯未读告诉显示
    $unreadMessige = D('user_message')->where(array('status'=>'1','receiveid'=>$_SESSION['user']['id']))->count();
    $this->assign('unreadMessige',$unreadMessige);
    $unreadGeet = D('hibox')->where(array('status'=>'1','touserid'=>$_SESSION['user']['id']))->count();
    $this->assign('unreadGeet',$unreadGeet);
    $unreadSysmessage = D('system_message')->where(array('status'=>'1','userid'=>$_SESSION['user']['id']))->count();
    $this->assign('unreadSysmessage',$unreadSysmessage);
    $unreadBesee = D('see')->where(array('status'=>'1','uid'=>$_SESSION['user']['id']))->count();
    $this->assign('unreadBesee',$unreadBesee);
    $unreadFensi = D('byattention')->where(array('status'=>'1','uid'=>$_SESSION['user']['id']))->count();
    $unreadWeibo = D('user')->field('chat')->where('id ='.$_SESSION['user']['id'])->find();
    $this->assign('unreadWeibo',$unreadWeibo);
    $unreadIncome = D('user')->field('income')->where('id ='.$_SESSION['user']['id'])->find();
    $this->assign('unreadIncome',$unreadIncome);
    // dump($unreadFensi);exit;
    $this->assign('unreadFensi',$unreadFensi);
    
}

// 用户的一些操作是否登录,没有则跳转至登录界面
public function _initialize() {parent::_initialize();
    if(!session('?user')) {$this->display('Login/login');
        exit();}
}

}

正文完
 0