一般是用mysql还是mysqli啊

WBOY
Release: 2016-06-23 13:52:45
Original
1130 people have browsed it

为什么会有mysqli啊


回复讨论(解决方案)

新版本的PHP都废弃mysql_系列函数了,显然建议用mysqli 啦。

mysqli是面向对象,当然也可以面向过程
面向对象

	$mysqli=new mysqli("localhost","root","123456","test");	if($mysqli->connect_error){		die("连接失败".$mysqli->conect_error);	}	$sql="select * from user1";	$res=$mysqli->query($sql);	while($row=$res->fetch_row()){		foreach($row as $k=>$v){			echo "--$v";		}		echo "</br>";	}	$res->free();	$mysqli->close();
Copy after login
Copy after login

面向过程
$mysqli=mysqli_connect("localhost","root","123456","test");	if(!$mysqli){		die("连接失败".mysqli_connect_error($mysqli));	}	$sql="select * from user1";	$res=mysqli_query($mysqli,$sql);	while($row=mysqli_fetch_row($res)){		foreach($row as $k=>$v){			echo "--$v";		}		echo "</br>";	}	mysqli_free_result($res);	mysqli_close($mysqli);
Copy after login
Copy after login

首选 PDO
其次 mysqli

首选 PDO
其次 mysqli



pdo是不是就是pdbc啊

mysqli是面向对象,当然也可以面向过程
面向对象

	$mysqli=new mysqli("localhost","root","123456","test");	if($mysqli->connect_error){		die("连接失败".$mysqli->conect_error);	}	$sql="select * from user1";	$res=$mysqli->query($sql);	while($row=$res->fetch_row()){		foreach($row as $k=>$v){			echo "--$v";		}		echo "</br>";	}	$res->free();	$mysqli->close();
Copy after login
Copy after login

面向过程
$mysqli=mysqli_connect("localhost","root","123456","test");	if(!$mysqli){		die("连接失败".mysqli_connect_error($mysqli));	}	$sql="select * from user1";	$res=mysqli_query($mysqli,$sql);	while($row=mysqli_fetch_row($res)){		foreach($row as $k=>$v){			echo "--$v";		}		echo "</br>";	}	mysqli_free_result($res);	mysqli_close($mysqli);
Copy after login
Copy after login



面向对象能不用坚决不用

PHP Data Objects (PDO)
php 内置的数据库抽象层

PHP Data Objects (PDO)
php 内置的数据库抽象层



那php下用odbc流行吗

Linux 中也用 ODBC 吗?

Linux 中也用 ODBC 吗?



也可以的,不过sql server的话,PDO_SQLSRV和PDO_ODBC应该用哪个啊,估计是odbc性能强

PDO_SQLSRV

ODBC 是通用接口,会忽视数据库的个性特征

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template