第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

正在回答

3 回答

重新寫(xiě),我現(xiàn)在用的也是PHP7.0的版本,不支持mysql擴(kuò)展,只有重新寫(xiě),自己定義業(yè)務(wù)邏輯,當(dāng)然了,只要你能看懂這個(gè)老師的代碼,自己寫(xiě)也應(yīng)該不會(huì)太難的

0 回復(fù) 有任何疑惑可以回復(fù)我~

問(wèn)下樓上 $str == null 報(bào)變量未定義錯(cuò)誤 怎么處理?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

星雨星辰

在if上面加上$str="";
2019-03-09 回復(fù) 有任何疑惑可以回復(fù)我~

用pdo吧? 目前基本都是pdo 會(huì)比較方便


<?php

/* 鏈接數(shù)據(jù)庫(kù) */
function connet() {
?? ?try {?? ??? ?
?? ??? ?$link = new PDO ( PDO_HOST, DB_USER, DB_PWD );
?? ??? ?$link->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
?? ??? ?/* $link->exec ( "set names" . DB_CHARSET ); */
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '數(shù)據(jù)庫(kù)連接失敗' . $e->getMessage ();
?? ?}
?? ?return $link;
}

/* 插入數(shù)據(jù) */
function insert($table, $array) {
?? ?try {
?? ??? ?$conn = connet ();
?? ??? ?$key = join ( ",", array_keys ( $array ) );
?? ??? ?$vals = "'" . join ( "','", array_values ( $array ) ) . "'";
?? ??? ?$sql = "insert into {$table} ({$key}) values({$vals})";
?? ??? ?$result = $conn->exec ( $sql );
?? ??? ?return $conn->lastInsertId ();
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '插入失敗' . $e->getMessage ();
?? ?}
}

/* 更新數(shù)據(jù) */
function update($table, $array, $where = null) {
?? ?try {
?? ??? ?$conn = connet ();
?? ??? ?foreach ( $array as $key => $val ) {
?? ??? ??? ?if ($str == null) {
?? ??? ??? ??? ?$sep = "";
?? ??? ??? ?} else {
?? ??? ??? ??? ?$sep = ",";
?? ??? ??? ?}
?? ??? ??? ?$str .= $sep . $key . "='" . $val . "'";
?? ??? ?}
?? ??? ?$sql = "update {$table} set {$str}" . ($where == null ? null : " where ". $where);
?? ??? ?$result = $conn->exec ( $sql );
?? ??? ?if ($result) {
?? ??? ??? ?return $result;
?? ??? ?} else {
?? ??? ??? ?return false;
?? ??? ?}
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '更新數(shù)據(jù)失敗' . $e->getMessage ();
?? ?}
}

/* 刪除數(shù)據(jù) */
function delete($table, $where = null) {
?? ?try {
?? ??? ?$conn = connet ();
?? ??? ?$where = $where == null ? null : " where " . $where;
?? ??? ?$sql = "delete from {$table} {$where}";
?? ??? ?$result = $conn->exec ( $sql );
?? ??? ?return $result;
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '刪除數(shù)據(jù)失敗' . $e->getMessage ();
?? ?}
}

/* 得到指定一條記錄 */
function fetchOne($sql, $result_type = PDO::FETCH_ASSOC) {
?? ?try {
?? ??? ?$conn=connet();
?? ??? ?$result=$conn->query($sql);
?? ??? ?$row=$result->fetch($result_type);
?? ??? ?return $row;
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '得到指定一條記錄失敗' . $e->getMessage ();
?? ?}
}

/* 得到所有結(jié)果 */
function fetchAll($sql, $result_type = PDO::FETCH_ASSOC) {
?? ?try {
?? ??? ?$conn = connet ();
?? ??? ?$result = $conn->query ( $sql );
?? ??? ?
?? ??? ?while ( @$row = $result->fetch($result_type)) {
?? ??? ??? ?$rows [] = $row;
?? ??? ?}
?? ??? ?return $rows;
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '得到所有結(jié)果失敗' . $e->getMessage ();
?? ?}
}
/* 得到所有結(jié)果條數(shù) */
function getResultNum($sql) {
?? ?try {
?? ??? ?$conn = connet ();
?? ??? ?$result = $conn->query ( $sql );
?? ??? ?$row_count = $result->rowCount ();
?? ??? ?return $row_count;
?? ?} catch ( PDOException $e ) {
?? ??? ?echo '得到所有結(jié)果條數(shù)失敗' . $e->getMessage ();
?? ?}
}

/**
?* 得到上一步插入記錄的ID號(hào)
?* @return number
?*/
function getInsertId(){
?? ?try {
?? ??? ?$conn = connet ();
?? ??? ?return $conn->lastInsertId();
?? ?} catch (PDOException $e) {
?? ??? ?echo '得到上一步插入記錄的ID號(hào)失敗' . $e->getMessage ();
?? ?}

}
?>

2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

星雨星辰

感謝大佬
2019-03-09 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
手把手教你實(shí)現(xiàn)電商網(wǎng)站后臺(tái)開(kāi)發(fā)
  • 參與學(xué)習(xí)       117248    人
  • 解答問(wèn)題       2101    個(gè)

手把手教你用PHP搭建電子商務(wù)平臺(tái),由淺入深教你搭建電商系統(tǒng)

進(jìn)入課程

mysql怎么轉(zhuǎn)換成mysqli,求代碼

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)