本文整理汇总了PHP中Stat::InsertIntoDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Stat::InsertIntoDatabase方法的具体用法?PHP Stat::InsertIntoDatabase怎么用?PHP Stat::InsertIntoDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stat
的用法示例。
在下文中一共展示了Stat::InsertIntoDatabase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: int
// Just in case someone has a older version of neon.
$sStatsTable = $database->CachedQuery("CREATE TABLE IF NOT EXISTS `stats` (`id` int(8) NOT NULL AUTO_INCREMENT, `result` varchar(8) NOT NULL, `type` varchar(65) NOT NULL, `timestamp` int(16) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;", array(), 1);
// Pull used/total memory for stats
$sFree = shell_exec('free');
$sFree = (string) trim($sFree);
$sFree_Array = explode("\n", $sFree);
$sMemory = explode(" ", $sFree_Array[1]);
$sMemory = array_filter($sMemory);
$sMemory = array_merge($sMemory);
$sUsedMemory = $sMemory[2];
$sTotalMemory = $sMemory[1];
// Pull server load for stats
$sLoad = sys_getloadavg();
$sLoad = $sLoad[0];
$sStat = new Stat(0);
$sStat->uType = "used_memory";
$sStat->uResult = $sUsedMemory;
$sStat->uTimestamp = time();
$sStat->InsertIntoDatabase();
$sStat = new Stat(0);
$sStat->uType = "total_memory";
$sStat->uResult = $sTotalMemory;
$sStat->uTimestamp = time();
$sStat->InsertIntoDatabase();
$sStat = new Stat(0);
$sStat->uType = "load";
$sStat->uResult = $sLoad;
$sStat->uTimestamp = time();
$sStat->InsertIntoDatabase();
$sOld = time() - 60 * 60 * 24;
$sStatsTable = $database->CachedQuery("DELETE FROM stats WHERE timestamp < '{$sOld}'", array(), 1);