Return array - multiple result
還沒有人認領這個 Issue。
評估
研究方向
首先追蹤 issue 中所示的 setting()->get() 呼叫,以及 da_settings 資料表中相符資料列的選取方式。使用範例資料驗證鍵、context 和 class 的 wildcard 情況;完成的標準是每個要求的相符結果都會回傳可使用的 array,同時不變更單值查詢。
由索引模型根據 Issue 內容生成。
描述
It is possible to get multiple values or an array as result?
e.g. - see code
Get all the settings from a specific key (App.theme) : setting()->get('App.theme','')
Get all the settings form a specific context : setting()->get('','user1')
Get all the settings from a specific class : setting()->get('Log')
$br='<br/>';
service('settings')->set('App.theme', 'dark', 'user1');
service('settings')->set('App.theme', 'white', 'user2');
service('settings')->set('App.theme', 'red', 'user3');
echo setting()->get('App.theme', 'user1').$br;
echo setting()->get('App.theme', 'user2').$br;
echo setting()->get('App.theme', 'user3').$br;
print_r(setting()->get('App.theme','*')).$br;
print_r(setting()->get('*','user1')).$br;
service('settings')->set('Log.location', 'site/log');
service('settings')->set('Log.date', '20220102');
service('settings')->set('Log.name', 'service');
echo setting()->get('Log.location').$br;
echo setting()->get('Log.date').$br;
echo setting()->get('Log.name').$br;
print_r (setting()->get('Log')).$br;
Sample database
-- Dumping structure for table ca70_assets.da_settings
CREATE TABLE IF NOT EXISTS `da_settings` (
`class` varchar(255) COLLATE armscii8_bin DEFAULT NULL,
`key` varchar(255) COLLATE armscii8_bin DEFAULT NULL,
`type` varchar(31) COLLATE armscii8_bin DEFAULT NULL,
`context` varchar(255) COLLATE armscii8_bin DEFAULT NULL,
`value` text COLLATE armscii8_bin DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=armscii8 COLLATE=armscii8_bin;
-- Dumping data for table ca70_assets.da_settings: ~11 rows (approximately)
INSERT INTO `da_settings` (`class`, `key`, `type`, `context`, `value`, `created_at`, `updated_at`) VALUES
('Config\\App', 'theme', 'string', 'user1', 'dark', '2023-01-02 16:10:06', '2023-01-02 16:14:10'),
('Config\\App', 'theme', 'string', 'user2', 'white', '2023-01-02 16:10:06', '2023-01-02 16:14:10'),
('Config\\App', 'theme', 'string', 'user3', 'red', '2023-01-02 16:10:06', '2023-01-02 16:14:10'),
('Log', 'location', 'string', NULL, 'site/log', '2023-01-02 16:13:08', '2023-01-02 16:14:10'),
('Log', 'date', 'string', NULL, '20220102', '2023-01-02 16:13:08', '2023-01-02 16:14:10'),
('Log', 'name', 'string', NULL, 'service', '2023-01-02 16:13:08', '2023-01-02 16:14:10');
- 主要語言
- PHP
- 星號
- 95
- 分支
- 29
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
相似的 Issue
-
needs triage
難度 2/5 1-3 小時 新手友好度 72/100
-
loginWithCustomTokenExchange() fails when an organization is configured可能已有人在做 @awss1i 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 2 天內回覆
-
type/bug
難度 1/5 1 小時以內 新手友好度 75/100
flarum/framework#5231 · 1 則留言 ·
維護者通常 1 天內回覆
-
major-release
難度 1/5 1 小時以內 新手友好度 67/100
Intervention/image#1553 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
omegaup/omegaup#10353 · 1 則留言 ·
維護者通常 5 天內回覆