
在fastadmin中, 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
而在index方法中,如果有表关联,并且需要关联查询时,需要设置当前是否为关联查询
// 当前是否为关联查询
$this->relationSearch = true;
否则在筛选时,如果关联的两个表中有相同的字段时会报错,比如两个表都有ID,则报错:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous
在打印参数时也有明显的区别
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
dump($where);
1、设置为关联查询时
["where"] => array(1) {
[0] => array(3) {
[0] => string(8) "store.id"
[1] => string(1) "="
[2] => string(3) "482"
}
}
["alias"] => array(1) {
["fa_store"] => string(5) "store"
}
2、未设置为关联查询时
["where"] => array(1) {
[0] => array(3) {
[0] => string(2) "id"
[1] => string(1) "="
[2] => string(3) "482"
}
}
["alias"] => array(0) {
}
发布时间 : 2025-05-10,阅读量:12