當我讀到J.Gilmore Zend的書(部分型號):Zend_Db。建立數據庫表時,我是否需要手動設置主鍵和外鍵?
class Game extends Zend_Db_Table_Abstract
{
protected $_primary='id'; //line 4
}
[..]Line 4 identifies the table's primary key.By default the framework will
presume the primary key is an automatically incrementing integer named id,so
this line is not necessary [..]
我有一個問題:
- 我是否需要手動設置主鍵和外鍵,同時建立一個表 (例。在phpmyadmin中有類似「PRIMARY KEY(id),FOREIGN KEY(post)REFERENCES users(id) ON DELETE CASCADE」)?
- 或者我可以使用$ _primary,$ _ dependentTable,$ _ referenceMap等來引用Zend代碼來處理表關係和字段自然?
感謝
盧卡
對於「兩者」+1。如果可能的話,同時使用安全性和完整性。 – Emerald214 2011-05-20 17:27:02