Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cod1ingcoding
Created August 23, 2017 03:52
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 cod1ingcoding/1bb92b30b23b215860de140f4e2df43b to your computer and use it in GitHub Desktop.
Save cod1ingcoding/1bb92b30b23b215860de140f4e2df43b to your computer and use it in GitHub Desktop.
<?php
// Eorder.php
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity @Table(name="e_orders", options={"collate"="utf8_general_ci"})
*/
class Eorder
{
/**
* @var integer
* @Id @GeneratedValue @Column(type="integer", name="order_id")
*/
protected $id;
public function getId() { return $this->id; }
/**
* @var OrderStockBatch[]|ArrayCollection
* @OneToMany(targetEntity="Eitem", mappedBy="order")
*/
protected $items;
public function __construct() {
$this->items = new ArrayCollection();
}
public function getItems() { return $this->items; }
public function setItems($items) { $this->items = $items; return $this; }
}
// Eitem.php
/**
* @Entity @Table(name="e_items", options={"collate"="utf8_general_ci"})
*/
class Eitem
{
/**
* @var integer
* @Id @GeneratedValue @Column(type="integer", name="item_id")
*/
protected $id;
public function getId() { return $this->id; }
public function __construct()
{
}
/**
* @var Eorder
* @ManyToOne(targetEntity="Eorder", inversedBy="items")
* @JoinColumn(name="order_id", referencedColumnName="order_id", onDelete="CASCADE") // 不用双向无法join column 到 item表
*/
protected $order;
/**
* @var integer
* @Column(type="integer", name="order_stock_batch_qty")
*/
protected $qty;
public function getQty() { return $this->qty; }
public function setQty($qty) { $this->qty = $qty; return $this; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment