php跨库复制备份表

需要定时把一些数据表备份,并做数据统计。
$dates=date('Ymd',time());

//player表的备份
$newtable = "PlayerLog" . $dates;
$sql = "CREATE TABLE ".$newtable." LIKE game_qd.Player";
$linelist = $logdb->exec($sql);
print_r($linelist);
echo "\n\r\n";
$sql2 = "INSERT INTO ".$newtable." SELECT * FROM game_qd.Player";
$linelist = $logdb->exec($sql2);
print_r($linelist);
echo "\n\r\n player done";
,主要的代码就两行。 还学会了left  join的用法,当时没想到,是解决了判断一个备份表里有,另一个备份表里没有是计算差值时的问题。  
	
$sql7 = "select a.PlayerID,a.Score,(a.Score-IFNULL(b.Score , 0)) as Scorecha from ".$formtable." as a left join ".$endtable." as b on a.PlayerID=b.PlayerID order BY Scorecha desc,Score desc limit ".$limitnum;
.

上一篇:
下一篇:

相关文章:

Categories: 博客记录

0 Responses so far.

Leave a Reply