电脑安全

您当前的位置:主页 > 电脑安全 >

php编写的ACCESS处理类-网络编程

来源:[db:来源]标题:   数组    编辑:电脑技术全能网 时间:2019-09-18 16:51

原标题:php编写的ACCESS处理类-网络编程
   在做名目中要用到ACCESS数据库,以是就写了一个ACCESS处置类.函数名跟ADODB类一样.<?php/**ACCESS数据库操纵类*2008-3-26*LIQUAN*$dsn="DRIVER={MicrosoftAccessDriver(*.mdb)};DBQ=".PATH_ROOT."databasedata.mdb";*$conn=newAccess();*$conn->Connnect($dsn);*$conn->GetArray("select*fromtest");*/classAccess{var$conn;var$fieldsName;functionAccess(){}//connectionfunctionConnect($dsn){$this->conn=newCOM("ADODB.Connection")ordie("CannotstartADO");$this->conn->Open($dsn);}//前往一个functionGetOne($sql){$rs=$this->conn->Execute($sql);while(!$rs->EOF){$value=$rs->Fields(0)->value;$rs->MoveNext();}$rs->Close();$rs=null;if(!empty($value)){return$value;}else{return"";}unset($value);}//前往大数组functionGetArray($sql){$rs=$this->conn->Execute($sql);$num_columns=$rs->Fields->Count();$rowcount=0;while(!$rs->EOF){for($i=0;$i<$num_columns;$i++){$fieldName[$rowcount][$rs->Fields($i)->name]=$rs->Fields($i)->value;}$rowcount++;$rs->MoveNext();}$rs->Close();$rs=null;if(!empty($fieldName)){return$fieldName;}else{return"";}unset($fieldName);}//前往小数组functionGetRow($sql){$rs=$this->conn->Execute($sql);$num_columns=$rs->Fields->Count();while(!$rs->EOF){for($i=0;$i<$num_columns;$i++){$fieldName[$rs->Fields($i)->name]=$rs->Fields($i)->value;}$rs->MoveNext();}$rs->Close();$rs=null;if(!empty($fieldName)){return$fieldName;}else{return"";}unset($fieldName);}//executeSQLfunctionExecute($sql){if($this->conn->Execute($sql)){returntrue;}else{returnfalse;}}functionClose(){$this->conn->Close();}function__destruct(){//$this->conn->Close();}}?>

上一篇:PHP5新特性,__autoload-网络编程

下一篇:没有了