orm 多库链接的情况无法在模型中通过$connection指定连接
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start at the selectInput(Request $request) method shown in the issue and trace how the model and database connection are selected before the table description query runs. Verify the multi-database case where a model specifies $connection, and consider the issue complete when the query uses that connection instead of assuming the mysql configuration.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
orm 多库链接的情况无法在模型中通过$connection指定连接
指定第二个库时,查询列表会报错 说第一个库不存在某表
排查到原因是
` protected function selectInput(Request $request): array
{
$field = $request->get('field');
$order = $request->get('order', 'asc');
$format = $request->get('format', 'normal');
$limit = (int)$request->get('limit', $format === 'tree' ? 1000 : 10);
$limit = $limit <= 0 ? 10 : $limit;
$order = $order === 'asc' ? 'asc' : 'desc';
$where = $request->get();
$page = (int)$request->get('page');
$page = $page > 0 ? $page : 1;
$table = config('plugin.admin.database.connections.mysql.prefix') . $this->model->getTable();
$allow_column = Util::db()->select("desc `$table`");
if (!$allow_column) {
throw new BusinessException('表不存在');
}
$allow_column = array_column($allow_column, 'Field', 'Field');
if (!in_array($field, $allow_column)) {
$field = null;
}
foreach ($where as $column => $value) {
if (
$value === '' || !isset($allow_column[$column]) ||
is_array($value) && (empty($value) || !in_array($value[0], ['null', 'not null']) && !isset($value[1]))
) {
unset($where[$column]);
}
}
// 按照数据限制字段返回数据
if (!Auth::isSuperAdmin()) {
if ($this->dataLimit === 'personal') {
$where[$this->dataLimitField] = admin_id();
} elseif ($this->dataLimit === 'auth') {
$primary_key = $this->model->getKeyName();
if (!Auth::isSuperAdmin() && (!isset($where[$primary_key]) || $this->dataLimitField != $primary_key)) {
$where[$this->dataLimitField] = ['in', Auth::getScopeAdminIds(true)];
}
}
}
return [$where, $format, $limit, $field, $order, $page];
}`
中config('plugin.admin.database.connections.mysql.prefix') 写死了这个mysql
- Lingua principale
- JavaScript
- Stelle
- 378
- Fork
- 48
- Merge medio
- 20h 9m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di webman-php/admin
-
js代码错误 Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
webman-php/admin#125 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
webman-php/admin#101 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
webman-php/admin#135 ·
-
在swoole驱动环境下,会出现问题 Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
webman-php/admin#133 ·
-
layui升级问题 Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
webman-php/admin#129 · 3 commenti ·
Tutte le issue di webman-php/admin
Issue simili
-
Update HugeIcons library Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
antfu-collective/icones#398 ·
-
ECmail.com Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
wesbos/burner-email-providers#554 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
components-web-app/docs#92 ·