Home >php教程 >PHP源码 >Memcached 海量数据 分片存储 (未完)

Memcached 海量数据 分片存储 (未完)

PHP中文网
PHP中文网Original
2016-05-25 17:12:05997browse

        跳至                 

<?php
require("dblib.php");
define("START_TIME", 5);
define("END_TIME", 7);
function formatQueryString($query){
	$array_result = explode(&#39; &#39;, $query);
	//取请求的sql语句, 分隔成array数组, 对N个小时的请求
	sscanf($array_result[START_TIME], "begin_time>&#39;%d-%d-%d&#39;", $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&#39;s passwd;
 * db: database
 */
function dbConnect($host, $name, $passwd, $db){
	if(!$link = mysql_connect($host, $name, $passwd)){
		printf(&#39;Connect to %s[name:%s passwd%s] failed.&#39;, $host, $name, $passwd);
		exit(-1);
	}
	
	if(!mysql_select_db($db, $link)){
		printf(&#39;No such database which name is %s.&#39;, $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;
	}
}
?>

                           

       

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn