나는 Doctrine에서 POS 시스템을 만들기 시작했습니다. 주문을 받고 있지만 Doctrine을위한 적절한 방법으로 하위 클래스를 설정했는지 여부에 대한 단서가 없습니다. 여기 Doctrine 서브 클래스를 올바르게하고 있습니까? 왜 오류입니까?
내가 주문 데이터베이스가 보이는lineItem: line_total, order_id, type
rentLineItem: returned_date_time, item_id, sold
buyLineItem: item_id
에 광고 항목과 함께 제공되는 모델입니다. 유형
여기class rentLineItem extends lineItem
{
public function setTableDefinition()
{
$this->hasColumn('returned_date_time','datetime');
$this->hasColumn('sold','tinyint', 2); // just in case it is sold at the end of the rental
$this->hasColumn('item_id','int');
}
public function setUp()
{
$this->hasOne('item', array('local' => 'item_id', 'foreign' => 'id'));
}
}
는 것입니다 (buyLineItem이 비슷) 1 (임대) 또는 2 (구매) 여기
이 여기class lineItem extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('line_total','int');
$this->hasColumn('order_id','int');
$this->setSubclasses(array(
'rentLineItem' => array('type' => 1),
'buyLineItem' => array('type' => 2),
)
);
}
public function setUp()
{
$this->hasOne('order', array('local' => 'order_id', 'foreign' => 'id'));
}
}
는 rentLineItem 클래스입니다 광고 항목이 클래스를입니다 중 하나입니다 코드 객체를 호출했습니다.
$q = Doctrine_Query::create()
->select('*')
->from('order')
->where('DATE(creation_date_time) = \'' . $theDate . '\'');
$orders = $q->execute();
$totalRents = 0;
$totalSales = 0;
foreach ($orders as $order) {
foreach ($order->line_items as $lineItem) {
if ($lineItem->type == 1) {
$totalRents++;
} else if ($lineItem->type == 2) {
$totalSales++;
}
}
}
여기에 오류가 있습니다.
Fatal error: Uncaught exception 'Doctrine_Record_UnknownPropertyException' with message 'Unknown record property/related component "type" on "lineItem"' in
/Developer/Projects/VEL/lib/vendor/doctrine/Doctrine/Record/Filter/Standard.php:55 Stack trace: #0
/Developer/Projects/VEL/lib/vendor/doctrine/Doctrine/Record.php(1296): Doctrine_Record_Filter_Standard->filterGet(Object(lLineItem), 'type') #1
/Developer/Projects/VEL/lib/vendor/doctrine/Doctrine/Record.php(1255): Doctrine_Record->_get('type', true) #2
/Developer/Projects/VEL/lib/vendor/doctrine/Doctrine/Access.php(72): Doctrine_Record->get('type') #3
/Developer/Projects/VEL/manage/manage/dailyincomeexpensereport.php(29): Doctrine_Access->__get('type') #4 {main} thrown in
/Developer/Projects/VEL/lib/vendor/doctrine/Doctrine/Record/Filter/Standard.php on line 55
내가 그 ... 그 오류를 제거하지만 내 코드에서 클래스를 호출하여 광고 항목을 가져 오면 해당 광고 항목을 rentLineItem 또는 buyLineItem으로 인식하지 못합니다 (lineItem –
). 위를 참조하십시오 ... 더 도움이되지 못해 미안 해요 ... –
doctrine은 내가 원하는 관계 유형을 지원하지 않는다고 생각합니다. –