第一類是一般的信息存放地表,第二個是等待表,用戶註冊(如等待名單)嘗試查詢兩個表,我無法弄清楚如何
+---------+--------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(30) | YES | | NULL | |
| userid | int(3) | YES | | NULL | |
| address | varchar(300) | YES | | NULL | |
| desc | varchar(550) | YES | | NULL | |
| phone | int(15) | YES | | NULL | |
| image | varchar(50) | YES | | NULL | |
| website | varchar(100) | YES | | NULL | |
| cat | varchar(25) | YES | | NULL | |
| date | timestamp | NO | | CURRENT_TIMESTAMP | |
+---------+--------------+------+-----+-------------------+----------------+
+----------+-----------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| userid | int(11) | YES | | NULL | |
| place_id | int(11) | YES | | NULL | |
| date | timestamp | NO | | CURRENT_TIMESTAMP | |
+----------+-----------+------+-----+-------------------+----------------+
現在我正在做一個SELECT * FROM的地方;並在主頁上顯示數據。像tihs:
<? foreach($places as $place): ?>
<? echo $place->name; ?>; <? echo $place->userid; ?> etc ...
<a href="#">Click this to insert your userid and $place->id into wait table</a>
<? endforeach ?>
這是我迷路了。我想這樣做:
<? if($current_user_id == $userid_from_wait_that_matches_place_id): ?>
<p>You already registered for this!</p>
<? else: ?>
<a href="#">Click this to insert your userid and $place->id into wait table</a>
<? endif; ?>
不知道它是更好的,增加了數據的等待表的模型來檢查用戶的ID或在該主頁抓取數據對模型進行檢查。從我讀過的內容來看,第二種選擇會更好。或者我應該使用兩個單獨的查詢?
我有一個用戶表。只需用戶數據。用戶名是「place」表中唯一的額外列。除此之外,它具有發佈用戶的ID。這就是它。 – Ciprian 2012-02-01 14:47:38
好吧...得到了固定我從表中刪除用戶現在唯一的信息是用戶名。 – Ciprian 2012-02-01 14:57:04
請檢查我的編輯! – uzsolt 2012-02-01 15:21:56