小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

myssqli和mysql的函數(shù)

 仴嗈黿嗌鄦嶜 2017-12-19

myssqli和mysql的函數(shù)是差不多的, 只不過, mysqi可以用對(duì)象方式

1
2
3
4
5
6
//過程方式:
 $Con = mysqli_connect('數(shù)據(jù)庫(kù)服務(wù)器地址''數(shù)據(jù)庫(kù)登陸用戶''數(shù)據(jù)庫(kù)密碼');
 mysqli_select_db( $Con'數(shù)據(jù)庫(kù)名稱');
 
//對(duì)象方式
$Con new mysqli('數(shù)據(jù)庫(kù)服務(wù)器地址''數(shù)據(jù)庫(kù)登陸用戶''數(shù)據(jù)庫(kù)密碼''數(shù)據(jù)庫(kù)名稱');

同樣是過程方式,mysqli有一點(diǎn)和mysql的用法不同的是,:

mysql函數(shù),很多函數(shù)都有2個(gè)參數(shù),一個(gè)是sql語(yǔ)句等, 一個(gè)是mysql連接標(biāo)識(shí), 而這個(gè)mysql連接標(biāo)識(shí)參數(shù)是可以省略的!

但是mysqli兩個(gè)參數(shù)必須, 而且順序相反, 比如:

1
2
3
4
5
mysql_query('show tables'$Con ); 
//也可以省略第二個(gè)參數(shù),寫成:
mysql_query('show tables');
//但是mysqli不行
mysqli_query( $Con,  'show tables');

其他回答

下個(gè)php手冊(cè),里面有示例代碼

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
$mysqli new mysqli('localhost''my_user''my_password''my_db');
/*
 * This is the "official" OO way to do it,
 * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
 */
if ($mysqli->connect_error) {
    die('Connect Error (' $mysqli->connect_errno . ') '
            $mysqli->connect_error);
}
/*
 * Use this instead of $connect_error if you need to ensure
 * compatibility with PHP versions prior to 5.2.9 and 5.3.0.
 */
if (mysqli_connect_error()) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}
echo 'Success... ' $mysqli->host_info . "\n";
$mysqli->close();

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多