簡體   English   中英

在PHP類方法MongoDate :: __ toString()中實例化MongoDate時出錯,不得在其中拋出異常

[英]Error instantiating MongoDate inside PHP class Method MongoDate::__toString() must not throw an exception in

我有以下代碼來創建與Mongo一起使用的自定義類

class MongoHandler{
    protected $col = NULL;
    protected $db;
    protected $timestamp;

    public function __construct($db_version) {
        // opening db connection
        $db = new MongoConnection();
        $this->db = $db->getMongoCon($db_version);
        $this->timestamp = new MongoDate();
    }
}

但是$ this-> timestamp = new MongoDate()產生以下錯誤:

PHP消息:PHP致命錯誤:方法MongoDate :: __ toString()不得在“

我想在與mongo交互(插入/更新)的所有方法中使用此時間戳。

將mongo php擴展名添加到您的php.ini中:

  extension=mongo.so

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM