最后執行$user->serial_no=rand(1000,90000); 為什么能保存到數據庫啊?
最后執行$user->serial_no=rand(1000,90000); 為什么能保存到數據庫??????這也是數據對象映射模式原理???還是這個屬于迭代器模式的一個用處?因為我沒看到你保存到數據庫在哪里保存的啊
最后執行$user->serial_no=rand(1000,90000); 為什么能保存到數據庫??????這也是數據對象映射模式原理???還是這個屬于迭代器模式的一個用處?因為我沒看到你保存到數據庫在哪里保存的啊
2016-09-16
舉報
2018-12-21
是在析構方法中實現的。
2016-12-29
這個問題好。??!么么噠
2016-10-05
user.php代碼需要修改一下
<?php namespace?IMooc; class?User { ????//數據庫表 ????public?$id; ????public?$name; ????public?$mobile; ????public?$regtime; ????public?$seril_no; ????protected?$data; ????protected?$db; ????function?__construct($id) ????{ ????????/** ?????????*?適配器模式-統一接口 ?????????*?工廠模式,在一個地方創建對象 ?????????*?注冊樹模式,同一個對象,只創建一次 ?????????*/ ????????$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']; ????} ????//析構方法 ????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"); ????} }2016-09-17
你再看一下第8章 數據對象映射模式~~多看看就知道了
2016-09-16
前面封裝好了呀,當對象destroy銷毀的時候寫的應該是