我想把我的 Zend 模型作为单例,所以我这样做了:
class Social_Model_DbTable_Dossier extends Zend_Db_Table_Abstract {
private static $_instance;
public static function GetInstance() {
if (!self::$_instance instanceof self) {
self::$_instance = new self();
}
return self::$_instance;
}
private function __construct() {
// put normal constructor code.
// it will only ever be called once
}}
我像这样实例化我的模型:
$dossiercasModel = Social_Model_DbTable_Dossier::GetInstance();
但是发生了这个错误:
Fatal error: Access level to Social_Model_DbTable_Dossier::__construct() must be public (as in class Zend_Db_Table_Abstract)
当我将模型的构造函数设为公共时,它可以正常工作,但这与单例的概念不一致!