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"; 

  • 相关阅读:
    python深浅拷贝
    pyinstaller打包py文件为exe方法
    python学习笔记3-关于文件的复制、重命名、移动、删除操作
    BeautifulSoup4 print() 输出中文乱码解决方法
    进程和线程的开启效率
    python3 使用pymysql
    python3 __file__
    Flask Template ( 模板学习)
    响应对象
    nginx 以及 uwsgi 的配置
  • 原文地址:https://www.cnblogs.com/y0umer/p/2809592.html
Copyright © 2011-2022 走看看