Sách Giáo Khoa Việt Nam - sachgiaokhoa.org
CodeIgniter 4 website:
- Catalog 999 SGK (lớp 1-12) từ API, lọc theo lớp/môn/NXB, tìm kiếm
- Trang chủ grouped browse (bậc học -> lớp -> môn, ưu tiên môn quan trọng)
- Chi tiết sách: metadata đầy đủ, cover nghệ thuật /thumb/{W}x{H}/
- Đọc online qua gate captcha + countdown, PDF viewer pdf.js
- Download: captcha + token một lần + auto cache-bust version
- Tự đồng bộ catalog/cover khi API thay đổi (refresh:catalog)
- Legal: DMCA, miễn trừ trách nhiệm, điều khoản, bảo mật, liên hệ
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use MongoDB\Client;
|
||||
|
||||
/**
|
||||
* MongoDB connection singleton (mongo-harness).
|
||||
*/
|
||||
class Mongo
|
||||
{
|
||||
private static ?Client $client = null;
|
||||
|
||||
public static function client(): Client
|
||||
{
|
||||
if (self::$client === null) {
|
||||
$uri = env('mongo.uri', 'mongodb://127.0.0.1:27017');
|
||||
self::$client = new Client($uri, ['serverSelectionTimeoutMS' => 5000]);
|
||||
}
|
||||
|
||||
return self::$client;
|
||||
}
|
||||
|
||||
public static function db(): \MongoDB\Database
|
||||
{
|
||||
return self::client()->selectDatabase((string) env('mongo.db', 'sachgiaokhoa'));
|
||||
}
|
||||
|
||||
public static function col(string $name): \MongoDB\Collection
|
||||
{
|
||||
return self::db()->selectCollection($name, ['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user