Answer the question
In order to leave comments, you need to log in
How to save a field of type CollectionType as an array to the database?
Everywhere examples of saving in relative table
and I need in the same table
/**
* @var string
*
* @ORM\Column(name="fields", type="json_array")
*/
private $fields;
public function __construct()
{
$this->fields = new \Doctrine\Common\Collections\ArrayCollection( );
}
$obj = new \stdClass;
$obj->name = "la";
$obj->number = 3;
$entity->setFields(json_encode([$obj]));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question