mysql擴(kuò)展進(jìn)行數(shù)據(jù)庫連接的方法:
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password');
mysqli擴(kuò)展:
$link = mysqli_connect('mysql_host', 'mysql_user', 'mysql_password');
PDO擴(kuò)展:
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
$dbh = new PDO($dsn, $user, $password);
數(shù)據(jù)庫操作
mysql_select_db('db');//選擇數(shù)據(jù)庫
mysql_query("set names 'utf8'");
數(shù)據(jù)庫查詢操作
$res = mysql_query("select * from db where id > 0");
$row = mysql_fetch_array($res);