as
class DB
{
var $hostName="localhost:3306";
var $rootName="root";
var $password="root";
var $database="ecbees";
var $Link_ID = 0; // Result of mysql_connect()
var $Query_ID = 0; // Result of most recent mysql_query()
function DB()
{
$this->Connect();
}
/*----------------------- 连接服务器,连接数据库 ------------------------*/
function Connect()
{
$this->Link_ID=mysql_connect($this->hostName,$this->rootName,$this->password) or die ("mysql connect failure!!!");
mysql_select_db($this->database, $this->Link_ID) or die ("database failure");
}
/*----------------访问数据库,并返回处理数据后传回的值 ------------------*/
function query($string)
{
$result = mysql_query($string,$this->Link_ID);
return $result;
}
function add($string)
{
$this->query($string);
return $this->insert_id();
}
function update($string)
{
return $this->query($string);
}
function delete($string)
{
return $this->query($string);
}
function get($string){
$res=$this->query($string);
return mysql_num_rows($res);
}
//最近一次对数据库查询受影响的行数
function affected_rows(){
if($this->Query_ID != 0) return mysql_affected_rows($this->Link_ID);
}
function insert_id(){
return mysql_insert_id($this->Link_ID);
}
function num_fields(){
if($this->Query_ID != 0)
return mysql_num_fields($this->Query_ID);
}
function fetch_row($result){
return mysql_fetch_row($result);
}
function fetch_array($result){
return mysql_fetch_array($result);
}
function test(){
return "this is class db test";
}
}
echo "saya";
$masa = 86400;
for($i = 1; $i < 50; $i += 1)
{
$masa = 86400*$i;
$masa1 = $masa+86400;
$ds = date("Y-m-d", time()-$masa);
$ds1 = date("Y-m-d", time()-$masa1);
$string="SELECT distinct loginid FROM login WHERE logintime > '".$ds1."' and logintime < '".$ds."'";
$result=$conn->query($string);
$array=$conn->fetch_array($result);
;
$kaki=$kaki.$ds1." - ".$ds. " = ".$result."
";
}
echo $kaki;
?>