Yii2 framework backup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.1 KiB

13 years ago
<?php
namespace yiiunit\data\ar;
class Order extends ActiveRecord
{
12 years ago
public function tableName()
13 years ago
{
return 'tbl_order';
}
13 years ago
12 years ago
public function customer()
13 years ago
{
12 years ago
return $this->hasOne('Customer', array('id' => 'customer_id'));
}
public function orderItems()
{
return $this->hasMany('OrderItem', array('order_id' => 'id'));
}
public function items()
{
return $this->hasMany('Item', array('id' => 'item_id'))
->via('orderItems')->orderBy('id');
}
public function books()
13 years ago
{
12 years ago
return $this->manyMany('Item', array('id' => 'item_id'), 'tbl_order_item', array('item_id', 'id'))
->where('category_id = 1');
13 years ago
}
12 years ago
public function customer()
{
return $this->hasOne('Customer', array('id' => 'customer_id'));
}
public function orderItems()
{
return $this->hasMany('OrderItem', array('order_id' => 'id'));
}
public function items()
{
return $this->hasMany('Item')
->via('orderItems', array('item_id' => 'id'))
->order('@.id');
}
public function books()
{
return $this->hasMany('Item')
->pivot('tbl_order_item', array('order_id' => 'id'), array('item_id' => 'id'))
->on('@.category_id = 1');
}
13 years ago
}