我有实体A和B(带有各自的表格)。这些实体具有N:M关系,因此有一个AB表。
A实体有一个disabled
布尔字段。
我希望使用ActiveRecord从A(are not disabled
或are in the AB table and belong to B entity with id 1
)获取所有实体。
示例:
A
| id | name | disabled |
| a1 | foo | false |
| a2 | bar | false |
| a3 | zoo | true |
| a4 | hoo | true |
B
| id | name |
| 1 | Bob |
| 2 | Jen |
AB
|Aid | Bid |
| a3 | 1 |
Bob的 A
个实体:foo
,bar
和zoo
。
答案 0 :(得分:1)
connect(pushButton_1x1, SIGNAL(clicked()), this, SLOT(button_1x1_clicked()));
connect(pushButton_2x2, SIGNAL(clicked()), this, SLOT(button_2x2_clicked()));
centralwidget->setLayout(horizontalLayout);
live_window->setCentralWidget(centralwidget);
live_window->setWindowTitle("Live View");
live_window->show();
}
void liveview::button_1x1_clicked()
{
qDebug() << "1 x 1";
Livecontroller->video_layout();
}
void liveview::button_2x2_clicked()
{
Livecontroller->video_layout();
}
答案 1 :(得分:1)
A.where(:disabled => false )
将找到A中未被禁用的所有条目,B.find_by_id(1).as
将找到A中属于B实体的所有条目,其ID为1. A.where(:disabled => false ) | B.find_by_id(1).as
2个数组提供所需的条目。
requeried_entries = A.where(:disabled => false ) | B.find_by_id(1).as