`
FZtree
  • 浏览: 110021 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

php小脚本

 
阅读更多
<?php

function std_echo($words){
  echo date('Y-m-d H:m:s')."\t".$words."\n";
}

  std_echo ('This is a job.');
  $host = "localhost";
  $username = "cc";
  $password = "cc";
  $database_test = "c0516";

  // 连接到数据库
  $con = mysql_connect($host, $username, $password);
  if (!$con){
    std_echo('Could not connect: '.mysql_error() );
    exit;
  }
  mysql_select_db($database_test, $con);

  // sql
  $add_time = time() - 5*60;
  $sql = ' UPDATE etz_borrow_investor'.
       ' SET close_time = add_time + 300'.
       ' WHERE close_time = 0 AND status = 7'.
       ' AND add_time <'.$add_time;

  // 执行sql
  $step = mysql_query($sql, $con);
  if (false === $step)
    std_echo ('Job Failed: '.mysql_error() );
  else
    std_echo ('Job Succed.');

  // 关闭连接
  mysql_close($con);
  exit;

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics