• mysql_query


    _______________________批量修改MySQL表前缀名称
    ALTER TABLE ssc__played RENAME TO ssc_played;
    ALTER TABLE ssc__played_group RENAME TO ssc_played_group;
    ALTER TABLE ssc__score_goods RENAME TO ssc_score_goods;
    ALTER TABLE ssc__score_swap RENAME TO ssc_score_swap;
    ALTER TABLE ssc__sysadmim_session RENAME TO ssc_sysadmim_session;
    ALTER TABLE ssc__sysadmin_bank RENAME TO ssc_sysadmin_bank;
    ALTER TABLE ssc__sysadmin_session RENAME TO ssc_sysadmin_session;
    ALTER TABLE ssc__sysmember RENAME TO ssc_sysmember;
    ALTER TABLE ssc__type RENAME TO ssc_type;
    
    select table_name FROM information_schema.tables;
    select table_name FROM information_schema.tables where table_name like 'xy_%';
    Select CONCAT( 'ALTER TABLE ', table_name, ' RENAME TO ssc', substring(table_name,5 ),';' )FROM information_schema.tables Where table_name LIKE 'ssc_%';
    
    
    @$con=mysql_connect("localhost","root","");
    mysql_select_db("abc",$con);
    mysql_query("set names utf8");
    //$sql="update user set agent_id=4 where id = 11";
    //$sql="insert into user (agent_id) VALUES ('4')";
    $sql="delete from user where id = 10537";
    $sql2="select agent_id from user where id = 11 limit 1";
    $rs=query($sql);
    $rs2=query($sql2);
    
    

    SELECT DATE_FORMAT( deteline, "%Y-%m-%d %H" ) , COUNT( * ) 
    FROM test

    GROUP BY DATE_FORMAT( deteline, "%Y-%m-%d %H" ) 

    查询某天:

    deteline, "%Y-%m-%d

    某时:

    deteline, "%Y-%m-%d %H"

    依次类推。

    其实就是对dateline进行处理,然后再对处理后的数据分组




    function query($sql){
    if(strstr($sql,"select")){
    $rs=mysql_query($sql);
    $res=array();
    while($row=mysql_fetch_assoc($rs)){
    array_push($res,$row);
    }
    return $res;
    }elseif(strstr($sql,"update")){
    $rs=mysql_query($sql);
    return $rs;
    }elseif(strstr($sql,"insert")){
    mysql_query($sql);
    $rs=mysql_insert_id();
    return $rs;
    }elseif(strstr($sql,"delete")){
    $rs=mysql_query($sql);
    return $rs;
    }

    }
    echo "<pre>";var_dump($rs);var_dump($rs2);exit;
    
    
    static public function Insert( $table, $condition )
    {
    self::Instance();

    $sql = "INSERT INTO `$table` SET ";
    $content = null;

    foreach ( $condition as $k => $v )
    {
    $v_str = null;
    if ( is_numeric($v) )
    $v_str = $v;
    else if ( is_null($v) )
    $v_str = 'NULL';
    else
    $v_str = "'" . self::EscapeString($v) . "'";

    $content .= "`$k`=$v_str,";
    }

    $content = trim($content, ',');
    $sql .= $content;

    $result = self::Query ($sql);
    if ( false==$result )
    {
    self::Close();
    return false;
    }

    return self::GetInsertId();
    }
  • 相关阅读:
    设计模式(十七)Observer模式
    设计模式(十六)Mediator模式
    设计模式(十五)Facade模式
    设计模式(十四)Chain of Responsibility模式
    设计模式(十三)Visitor模式
    设计模式(十一)Composite模式
    设计模式(十二)Decorator模式
    设计模式(十)Strategy模式
    python 函数编程
    python import hashllb
  • 原文地址:https://www.cnblogs.com/csjoz/p/7243901.html
Copyright © 2020-2023  润新知