Doctrine Many to Many Insert
You have lot of errors (pay attention to grammar):
instead of
public $categories;public function __construct() { $this->category = new \Doctrine\Common\Collections\ArrayCollection();}
it should be:
protected $categories;public function __construct() { $this->categories = new \Doctrine\Common\Collections\ArrayCollection();}
instead of:
public $user;public function __construct() { $this->user = new \Doctrine\Common\Collections\ArrayCollection();}
use
protected $users;public function __construct() { $this->users = new \Doctrine\Common\Collections\ArrayCollection();}
Instead of
public function addCategories(Category $category = null){ $this->categories = $category;}
it must be
public function addCategory(Category $category = null){ $this->categories->add($category);}
and
public function removeCategory(Category $category){ $this->categories->removeElement($category) ;}public function setCategories($categories){ $this->categories = categories;}
Same logic on both sides. I don't know how CI works but Symfony will automatically find addSomething/removeSomething methods. Even if CI doesn't support that feature, you should still change your code as above.