查询非常简单:
Eg 1: "UPDATE threads SET hits = hits+1 WHERE id = TID"
Eg 2: "UPDATE users SET last_activity = unix_timestamp() WHERE id = UID"
`users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`last_activity` int(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
`threads` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`hits` int(10) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci我们以这个查询为例:
mysql_query("UPDATE users SET last_activity = unix_timestamp() WHERE id = UID");没有查询,脚本需要约30毫秒才能执行:
与查询,脚本需要约110毫秒执行:
最好的问候,Duluman Edi
LE:生成执行时间的代码如下所示:
///this is placed above any code
$mtime = explode(' ',microtime());
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
.....
my game code is here
.....
$mtime = explode(' ',microtime());
echo lang('info','page_load').' '.number_format(($mtime[1] + $mtime[0]) - $tstart,4,'.','')*1000;这就是我计算执行时间的方式,它非常准确,永远不会让我失望。
附: - 真正的执行时间低了大约15毫秒,因为我现在在Windows上托管这个。