标签:
//连接数据库 function conn($dbhost,$dbuser,$dbpwd,$dbname) { $link = @mysql_connect($dbhost,$dbuser,$dbpwd) or die("连接数据库错误!".mysql_error()); mysql_select_db($dbname,$link); mysql_query("set names utf8"); } //执行sql语句 function query($sql) { return mysql_query($sql); } //返回记录数 function numRows($sql) { $result = mysql_query($sql); return mysql_num_rows($result); } //获取一条信息,返回一维数组 function getOne($sql) { $result = mysql_query($sql); return mysql_fetch_assoc($result); } //获取多条信息,返回多维数组 function getAll($sql) { $result = mysql_query($sql); $rows = array(); while($rs = mysql_fetch_assoc($result)) { $rows[] = $rs; } return $rows; } //关闭数据库 function close() { mysql_close(); }
<?php $config = array( ‘dbhost‘=>‘localhost‘, ‘dbuser‘=>‘root‘, ‘dbpwd‘=>‘‘, ‘dbname‘=>‘myblog‘ );
标签:
原文地址:http://www.cnblogs.com/phpweige/p/4817790.html