$field) { if (in_array($field['type'], ['text', 'textarea', 'url'], true)) $searchable[] = "`$name` LIKE ?"; } if ($searchable) { $where[] = '(' . implode(' OR ', $searchable) . ')'; foreach ($searchable as $_) $params[] = '%' . $query . '%'; } } if ($status !== '' && isset($module['fields']['status'])) { $where[] = '`status` = ?'; $params[] = $status; } $whereSql = $where ? ' WHERE ' . implode(' AND ', $where) : ''; $countStmt = db()->prepare('SELECT COUNT(*) FROM `' . $module['table'] . '`' . $whereSql); $countStmt->execute($params); $total = (int) $countStmt->fetchColumn(); $pages = max(1, (int) ceil($total / $perPage)); $page = min($page, $pages); $offset = ($page - 1) * $perPage; $stmt = db()->prepare('SELECT * FROM `' . $module['table'] . '`' . $whereSql . ' ORDER BY ' . $module['order'] . " LIMIT $perPage OFFSET $offset"); $stmt->execute($params); $rows = $stmt->fetchAll(); $relations = []; foreach ($module['fields'] as $name => $field) { if ($field['type'] === 'relation') { $relations[$name] = []; foreach (db()->query("SELECT id, title FROM `{$field['table']}`")->fetchAll() as $rel) $relations[$name][$rel['id']] = $rel['title']; } } render_header($module['label'], $key); ?>
新增資料

清單

筆;每頁

編號操作
#編輯
找不到符合條件的資料。
1): ?>