zoukankan      html  css  js  c++  java
  • left 截取

    select min(online) as onlinenum from tb_log_online where left(time,10)= '".substr($fromTime1,0,10)."' 
    截取时间段的左前十位 



    解决中文被截成乱码的问题 
    以下是代码片段: 
    function left(?$str, ?$len) { //解决中文被截成乱码的问题 
    ?$arr = str_split(?$str); 
    ?$i = 0; 
    foreach (?$arr as ?$chr) { 
    if (ord(?$chr) > 128) 
    ?$add = ?$add ? 0 : 1; 
    ?$i++; 
    if (?$i == ?$len) 
    break; 

    return substr(?$str, 0, ?$len + ?$add); 





    $addsql.="where 1=1"; 
    $fromTime && $addsql .= " and ctime>='$fromTime'"; 

    &&运算机制:如果 $fromTime为真,执行$addsql,得到$addsql=where 1=1 and ctime>='$fromTime' 
    如果$fromTime为假,不再执行 

    以上代码= 
    $addSql .= $fromTime ? " and `time`> = $fromTime" : "";  三目运算: 


    ¥sql语句分析:实现了按照三种类型排序的功能 
    public static function topN($orderType,$top){ 
    if(!$orderType) return false; 
    if(!$top) $top = 10 ; 
    $types = array('user_credit', 'user_wenxun','user_wuxun'); 
    $orderType = trim($orderType); if(!in_array($orderType,$types)) return false; 

    $sql="select user_id,user_name,user_character,user_countryID,user_uri,user_gold,user_point,user_credit,user_wenxun,user_wuxun,user_jsjqd from tb_user where `user_character`!='' ". 
    "order by $orderType desc limit 0,$top"; 

  • 相关阅读:
    H5相关网址
    ASP.NET MVC Razor视图引擎攻略
    深度解析 ASP.NET MVC 5
    .Net MVC 框架基础知识
    java SDK服务端推送 --极光推送(JPush)
    Nexus Repository Manager OSS 3.x 安装配置
    java项目中使用ffmpeg剪辑部分视频
    net 异步与同步
    IDEA把spring-boot项目打包成jar
    开放api接口签名验证
  • 原文地址:https://www.cnblogs.com/y0umer/p/2809592.html
Copyright © 2011-2022 走看看