Note that there are some explanatory texts on larger screens.

plurals
  1. PODoctrine inconsistently and silently fails to load model
    primarykey
    data
    text
    <p>Ok, I'm using Doctrine2 in Codeigniter along the lines of <a href="http://www.joelverhagen.com/blog/2011/05/setting-up-codeigniter-2-with-doctrine-2-the-right-way/" rel="nofollow">Joel Verhagen</a> and things have been working fine, but now I have a mysterious issue.</p> <p>When destroying an item things work fine:</p> <pre><code>$delete = $this-&gt;doctrine-&gt;em-&gt;getRepository('Entities\Item')-&gt;findOneBy(array('slug' =&gt; $item)); $this-&gt;doctrine-&gt;em-&gt;remove($delete); $this-&gt;doctrine-&gt;em-&gt;flush(); </code></pre> <p>but updating an item fails, silently, right after the getRepository():</p> <pre><code>$item = $this-&gt;doctrine-&gt;em-&gt;getRepository('Entities\Item')-&gt;findOneBy(array('id' =&gt; $id)); $item-&gt;setDescription(html_entity_decode($_POST['content'])); $this-&gt;doctrine-&gt;em-&gt;persist($item); $this-&gt;doctrine-&gt;em-&gt;flush(); </code></pre> <p>Same controller, and that is all the code in each action. All of my other controllers are fine, but this fails with nothing in any logs. Splitting the getRepository and find calls dies right after the getRepository. Moving the getRepository into the __construct causes update() to die with the find.</p> <p>Thoughts? Leads? It seems anyone else on SO ends up either going a different direction or never having solved the problem.</p> <p>Thanks!</p> <hr> <p>Edit: Add Models</p> <p>Yaml</p> <p>Item</p> <pre><code>Entities\Item: type: entity table: items id: id: type: integer primary: true notnull: true generator: strategy: AUTO fields: title: type: string(255) notnull: true slug: type: string(255) notnull: true description: type: string(255) manyToOne: type: targetEntity: Type inversedBy: item joinColumn: name: type_id referencedColumnName: id options: charset: utf8 type: InnoDB </code></pre> <p>Type</p> <pre><code>Entities\Type: type: entity table: types id: id: type: integer primary: true notnull: true generator: strategy: AUTO fields: title: type: string(255) notnull: true slug: type: string(255) notnull: true description: type: string(255) oneToMany: items: targetEntity: Item orphanRemoval: true mappedBy: type manyToMany: fields: targetEntity: Field inversedBy: types joinTable: name: fields_types joinColumns: type_id: referencedColumnName: id inverseJoinColumns: field_id: referencedColumnName: id options: charset: utf8 type: InnoDB </code></pre> <hr> <p>PHP</p> <p>Item</p> <pre><code>&lt;?php namespace Entities; use Doctrine\ORM\Mapping as ORM; /** * Entities\Item */ class Item { /** * @var integer $id */ private $id; /** * @var string $title */ private $title; /** * @var string $description */ private $description; /** * @var \Doctrine\Common\Collections\ArrayCollection */ private $fields; /** * Constructor */ public function __construct() { $this-&gt;fields = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this-&gt;id; } /** * Set title * * @param string $title * @return Item */ public function setTitle($title) { $this-&gt;title = $title; return $this; } /** * Get title * * @return string */ public function getTitle() { return $this-&gt;title; } /** * Set description * * @param string $description * @return Item */ public function setDescription($description) { $this-&gt;description = $description; return $this; } /** * Get description * * @return string */ public function getDescription() { return $this-&gt;description; } /** * Add fields * * @param Entities\Field $fields * @return Item */ public function addField(\Entities\Field $fields) { $this-&gt;fields[] = $fields; return $this; } /** * Remove fields * * @param Entities\Field $fields */ public function removeField(\Entities\Field $fields) { $this-&gt;fields-&gt;removeElement($fields); } /** * Get fields * * @return Doctrine\Common\Collections\Collection */ public function getFields() { return $this-&gt;fields; } /** * @var Entities\Type */ private $types; /** * Set types * * @param Entities\Type $types * @return Item */ public function setTypes(\Entities\Type $types = null) { $this-&gt;types = $types; return $this; } /** * Get types * * @return Entities\Type */ public function getTypes() { return $this-&gt;types; } /** * @var Entities\Type */ private $type; /** * Set type * * @param Entities\Type $type * @return Item */ public function setType(\Entities\Type $type = null) { $this-&gt;type = $type; return $this; } /** * Get type * * @return Entities\Type */ public function getType() { return $this-&gt;type; } /** * @var string $slug */ private $slug; /** * Set slug * * @param string $slug * @return Item */ public function setSlug($slug) { $this-&gt;slug = $slug; return $this; } /** * Get slug * * @return string */ public function getSlug() { return $this-&gt;slug; } } </code></pre> <p>Type</p> <pre><code>&lt;?php namespace Entities; use Doctrine\ORM\Mapping as ORM; /** * Entities\Type */ class Type { /** * @var integer $id */ private $id; /** * @var string $title */ private $title; /** * @var string $description */ private $description; /** * @var \Doctrine\Common\Collections\ArrayCollection */ private $items; /** * Constructor */ public function __construct() { $this-&gt;items = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this-&gt;id; } /** * Set title * * @param string $title * @return Type */ public function setTitle($title) { $this-&gt;title = $title; return $this; } /** * Get title * * @return string */ public function getTitle() { return $this-&gt;title; } /** * Set description * * @param string $description * @return Type */ public function setDescription($description) { $this-&gt;description = $description; return $this; } /** * Get description * * @return string */ public function getDescription() { return $this-&gt;description; } /** * Add items * * @param Entities\Item $items * @return Type */ public function addItem(\Entities\Item $items) { $this-&gt;items[] = $items; return $this; } /** * Remove items * * @param Entities\Item $items */ public function removeItem(\Entities\Item $items) { $this-&gt;items-&gt;removeElement($items); } /** * Get items * * @return Doctrine\Common\Collections\Collection */ public function getItems() { return $this-&gt;items; } /** * @var \Doctrine\Common\Collections\ArrayCollection */ private $fields; /** * Add fields * * @param Entities\Field $fields * @return Type */ public function addField(\Entities\Field $fields) { $this-&gt;fields[] = $fields; return $this; } /** * Remove fields * * @param Entities\Field $fields */ public function removeField(\Entities\Field $fields) { $this-&gt;fields-&gt;removeElement($fields); } /** * Get fields * * @return Doctrine\Common\Collections\Collection */ public function getFields() { return $this-&gt;fields; } /** * @var string $slug */ private $slug; /** * Set slug * * @param string $slug * @return Type */ public function setSlug($slug) { $this-&gt;slug = $slug; return $this; } /** * Get slug * * @return string */ public function getSlug() { return $this-&gt;slug; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload