PHP经验集锦
SERVER,$dbUser=USER,$userPassword=PASSWORD,$database=DATABASE){ switch($this->dbType){ case 1: $this->dbLink=@mysql_pconnect($dbHost,$dbUser,$userPassword);// or die("Can''t Connect to Remote Host!"); @mysql_select_db($database,$this->dbLink);// or die ("Can''t Connect to Remote Host!"); break; case 2: break; } return true; } /*SQL:Select() 返回为false无结果*/ function Select($table,$columns,$condition=1){ $sql="select $columns from $table where $condition "; //echo $sql."<br>"; $this->result=@mysql_query($sql,$this->dbLink); unset($this->rows); if($this->result){ $i=0; if(!($this->rows=array("$i"=>@mysql_fetch_array($this->result)))) return false; if(($this->numRows=@mysql_num_rows($this->result))==0) return false; while()){ array_push($this->rows,$tempRows); } }else{ $this->Halt($sql); return false; } return true; } /*SQL:GetRows() 返回查询的记录总数*/ function GetRows($table,$condition=1){ $sql="select count(1) as count from $table where $condition"; //echo $sql."<br>"; $this->result=@mysql_query($sql,$this->dbLink); if($this->result){ ); $this->numRows=$temp[count]; }else{ $this->Halt($sql); return false; } return $this->numRows; } /*SQL:Insert()*/ function Insert($table,$columns,$values){ $sql="insert into $table ($columns) values ($values)"; //echo $sql; $this->result=@mysql_query($sql,$this->dbLink); if ($this->result) $this->insId=@mysql_insert_id($this->dbLink); else{ $this->Halt($sql); return false; } return true; } /*SQL:Update()*/ /*SQL:Delete*/ |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |