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

為了賬號安全,請及時綁定郵箱和手機立即綁定

最后執(zhí)行$user->serial_no=rand(1000,90000); 為什么能保存到數(shù)據(jù)庫?。?/h1>

最后執(zhí)行$user->serial_no=rand(1000,90000); 為什么能保存到數(shù)據(jù)庫??????這也是數(shù)據(jù)對象映射模式原理???還是這個屬于迭代器模式的一個用處?因為我沒看到你保存到數(shù)據(jù)庫在哪里保存的啊

正在回答

5 回答

是在析構(gòu)方法中實現(xiàn)的。

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

這個問題好。?。∶疵磭}

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

user.php代碼需要修改一下

<?php
namespace?IMooc;

class?User
{
????//數(shù)據(jù)庫表
????public?$id;
????public?$name;
????public?$mobile;
????public?$regtime;
????public?$seril_no;

????protected?$data;
????protected?$db;

????function?__construct($id)
????{
????????/**
?????????*?適配器模式-統(tǒng)一接口
?????????*?工廠模式,在一個地方創(chuàng)建對象
?????????*?注冊樹模式,同一個對象,只創(chuàng)建一次
?????????*/
????????$this->db?=?\IMooc\Factory::createDBMySQLi();
????????$this->db->connect('localhost',?'root',?'',?'test',?'utf8');
????????$res?=?$this->db->query("select?*?from?user?where?id?=?{$id}?limit?1");
????????$data?=?$res->fetch_assoc();

????????$this->id?=?$data['id'];
????????$this->name?=?$data['name'];
????????$this->mobile?=?$data['mobile'];
????????$this->regtime?=?$data['regtime'];
????????$this->seril_no?=?$data['seril_no'];
????}

????//析構(gòu)方法
????function?__destruct()
????{
????????$this->db->query("update?user?set?name?='{$this->name}',?mobile='{$this->mobile}',
??????????regtime='{$this->regtime}',?seril_no='{$this->seril_no}'??where?id?=?{$this->id}?limit?1");
????}
}


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

你再看一下第8章 數(shù)據(jù)對象映射模式~~多看看就知道了

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

前面封裝好了呀,當對象destroy銷毀的時候?qū)懙膽?yīng)該是

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

舉報

0/150
提交
取消

最后執(zhí)行$user->serial_no=rand(1000,90000); 為什么能保存到數(shù)據(jù)庫啊?

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

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

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