簡體   English   中英

在Document中使用哈希時出現“數組到字符串轉換”錯誤

[英]“Array to string conversion” error when using hash in Document

我正在嘗試使用文檔的哈希類型。 當我創建一個對象時沒有問題,但是當我嘗試檢索文檔時,我得到一個“數組到字符串轉換”。

我簡化了文件。 僅當我添加此哈希屬性時才開始發生此數組到字符串轉換。

看看symfony的轉儲消息,它似乎來自保濕器。

Doctrine試圖將數據轉換為字符串的任何想法?

class MyDocument
{
   /**
    * @MongoDB\Id
    */
   protected $id;

   /**
    * @MongoDB\Field(type="hash")
    */
   protected $value = array();

}

在我的一項服務中的某個地方:

$product = 
  $this->container->get('doctrine_mongodb')
  ->getRepository('XTradBundle:Traduction')
  ->findAll();

堆棧跟蹤:

in var\cache\dev\doctrine\odm\mongodb\Hydrators\WeBSurgTradBundleDocumentTraductionHydrator.php at line 84   -
     if (isset($data['value']) || (! empty($this->class->fieldMappings['value']['nullable']) && array_key_exists('value', $data))) {
        $value = $data['value'];
        if ($value !== null) {
            //Why is it converting it to a string here?
            $return = (string) $value;
        } else {
            $return = null;
        }

似乎$value in protected $value = array(); 是保留名稱。 簡單地將其命名為其他東西可以解決問題。

暫無
暫無

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

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