'127.0.0.1',
'pass'=>'root',
'user'=>'root',
'name'=>'test',
);
$db=array();
$db\['conn'\] = mysql\_connect($db\_conf\['host'\], $db\_conf\['user'\], $db\_conf\['pass'\]) or die("connect failed: " . mysql\_error());
mysql\_select\_db($db\_conf\['name'\], $db\['conn'\]) or die ("select db failed: " . mysql\_error());
//单条读取
$db\['sql'\]="SELECT \* FROM tt\_user where username='aaa' LIMIT 0,1";
$db\['result'\]=mysql\_query($db\['sql'\],$db\['conn'\]) or die ("mysql\_query failed: " . mysql\_error());
$db\_row=mysql\_fetch\_row($db\['result'\],MYSQL\_ASSOC);
print\_r($db\_row);
//多条读取
$db\['sql'\]='SELECT \* FROM tt\_user LIMIT 0,10';
$db\['result'\]=mysql\_query($db\['sql'\],$db\['conn'\]);
while ($db\_row=mysql\_fetch\_array($db\['result'\],MYSQL\_ASSOC)){
print\_r($db\_row);
}
//关闭连接
mysql\_free\_result($db\['result'\]);
mysql\_close($db\['conn'\]);
MYSQL_基本实例_mysql
点赞
收藏