Memcached 海量数据 分片存储 (未完)
程序员文章站
2022-05-14 11:15:54
...
跳至
<?php require("dblib.php"); define("START_TIME", 5); define("END_TIME", 7); function formatQueryString($query){ $array_result = explode(' ', $query); //取请求的sql语句, 分隔成array数组, 对N个小时的请求 sscanf($array_result[START_TIME], "begin_time>'%d-%d-%d'", $s_year, $s_mouth, $s_day);//开始时间 sscanf($array_result[END_TIME], "begin_time
2. [文件] dblib.php ~ 728B
<?php /* dbConnect * host: ip; * name: mysql user; * passwd: user's passwd; * db: database */ function dbConnect($host, $name, $passwd, $db){ if(!$link = mysql_connect($host, $name, $passwd)){ printf('Connect to %s[name:%s passwd%s] failed.', $host, $name, $passwd); exit(-1); } if(!mysql_select_db($db, $link)){ printf('No such database which name is %s.', $db); exit(-1); } return $link; } /* dbQuery * sql: select query */ function dbQuery($sql, $link){ if(!$result = mysql_query($sql, $link)){ echo mysql_errno($link) . ": " . mysql_error($link) . "\n"; return FALSE; }else{ while ($row=mysql_fetch_assoc($result)){ $arr[]=$row; } return $arr; } } ?>