Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/3cc377385b9ddca9269d to your computer and use it in GitHub Desktop.
Save doctrinebot/3cc377385b9ddca9269d to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-1017 - https://github.com/doctrine/doctrine2/issues/1603
<?php
namespace Maia\Model;
/**
* @Entity
*
*/
class Task
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
protected $id;
// first scenario:
/**
* @ManyToOne(targetEntity="Maia\Model\User", inversedBy="tasks")
*/
protected $user;
// new scenario (which results in an error when updating)
# /**
# * @ManyToOne(targetEntity="Maia\Model\User", inversedBy="tasks")
# */
# protected $author;
}
<?php
namespace Maia\Model;
/**
* @Entity
*/
class User
{
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
protected $id;
// first scenario:
/**
* @OneToMany(targetEntity="Maia\Model\Task", mappedBy="user")
*/
protected $tasks;
// new scenario (which results in an error when updating)
# /**
# * @OneToMany(targetEntity="Maia\Model\Task", mappedBy="author")
# */
# protected $tasks;
}
-- phpMyAdmin SQL Dump
-- version 3.3.8.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 04, 2011 at 08:41 PM
-- Server version: 5.1.49
-- PHP Version: 5.3.3-1ubuntu9.3
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `maia`
--
-- --------------------------------------------------------
--
-- Table structure for table `User`
--
CREATE TABLE IF NOT EXISTS `User` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `User`
--
INSERT INTO `User` (`id`) VALUES
(1);
-- --------------------------------------------------------
--
-- Table structure for table `Task`
--
CREATE TABLE IF NOT EXISTS `Task` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`auteur_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Task_user_id_idx` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `Task`
--
INSERT INTO `Task` (`id`, `user_id`) VALUES
(1, 1);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `Task`
--
ALTER TABLE `Task`
ADD CONSTRAINT `Task_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `User` (`id`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment