{"id":27624221,"url":"https://github.com/alexsoft-software/jsql","last_synced_at":"2025-04-23T11:23:20.665Z","repository":{"id":289360037,"uuid":"970422612","full_name":"alexsoft-software/jsql","owner":"alexsoft-software","description":"JSQLDB is a \"lightweight, JSON-powered database system\" designed for PHP applications. It provides \"SQL-like queries\" with the flexibility of JSON storage, \"eliminating the need\" for traditional database dependencies like SQLite or MySQL.","archived":false,"fork":false,"pushed_at":"2025-04-22T21:22:56.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T22:24:42.426Z","etag":null,"topics":["ascoos","ascoos-framework","database","json","php8","sql"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexsoft-software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_AGL-F.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-22T02:03:01.000Z","updated_at":"2025-04-22T21:22:59.000Z","dependencies_parsed_at":"2025-04-22T22:24:44.982Z","dependency_job_id":"37bf7cd1-78df-4fd2-bc64-ea1ff424b7a3","html_url":"https://github.com/alexsoft-software/jsql","commit_stats":null,"previous_names":["alexsoft-software/jsql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsoft-software%2Fjsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsoft-software%2Fjsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsoft-software%2Fjsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexsoft-software%2Fjsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexsoft-software","download_url":"https://codeload.github.com/alexsoft-software/jsql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250422736,"owners_count":21428008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascoos","ascoos-framework","database","json","php8","sql"],"created_at":"2025-04-23T11:23:20.194Z","updated_at":"2025-04-23T11:23:20.664Z","avatar_url":"https://github.com/alexsoft-software.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# **JSQLDB - JSON SQL Database for PHP**\r\n\r\n## 💬 **A lightweight, SQL-like JSON-based database for PHP**  \r\n\r\n**JSQLDB** is a **flexible database system** that **leverages JSON** for storage and provides **SQL-like queries** without requiring SQLite or MySQL. It’s **lightweight, fast**, and **perfect** for applications that need **portability and security**.\r\n\r\n---\r\n\r\n![JSQL Database](https://s.ascoos.com/images/jsql/jsqldb.jpg)\r\n\r\n---\r\n\r\n### 🚀 **Features**\r\n- ✅ **JSON-based storage** without DLL/SO dependencies  \r\n- ✅ **SQL-like queries** with support for `SELECT`, `INSERT`, `UPDATE`, `DELETE`, `JOIN`, `UNION`, `GROUP BY`, `HAVING`, `LIMIT`, `ORDER BY`, `DISTINCT` etc.\r\n- ✅ **Indexing support** for fast searching  \r\n- ✅ **Compressed storage** for optimized resource usage  \r\n- ✅ **Customizable storage path** for secure data management  \r\n- ✅ **Optimized for PHP 8.2+**  \r\n\r\n---\r\n\r\n### 🧩 Requires:\r\n- PHP 8.2+\r\n- Ascoos Framework (For high level access, and managed)\r\n- ionCube Loaders\r\n\r\n---\r\n\r\n### **💻 Installation**\r\n\r\n```bash\r\ngit clone https://github.com/alexsoft-software/jsql.git\r\ncd jsql\r\ncomposer install\r\n```\r\n\r\n✏️ **More details coming soon in the documentation!**\r\n\r\n---\r\n\r\n## 📌 **Using the Database**\r\n\r\nThe database must be initialized before using it. This is done through the settings file.\r\n\r\n\r\n### **📑 Example Settings**\r\n```php\r\n\r\nreturn [\r\n    'jsql' =\u003e [\r\n        'config_path' =\u003e '/root/path/conf/config.json', \r\n        'users_path' =\u003e '/root/path/conf/users.json',\r\n        'databases_root_path' =\u003e '/root/path/jsql_db',      \r\n    ]\r\n];\r\n```\r\n\r\n### **📑 Example Usage**\r\n\r\n```php\r\n\u003c?php\r\nuse ASCOOS\\FRAMEWORK\\Kernel\\DB\\JSQLDB;\r\n\r\n// We read from the settings file the operating parameters of the database.\r\n$conf = require \"conf/config.php\";\r\n\r\n$properties['tables_prefix'] = 'ascoos'; // It will give e.g. a \"ascoos_articles' table.\r\n\r\n// Initialize the database object\r\n$jsql = new TJSQLDB($conf, $properties);\r\n\r\n// Create Database\r\n$jsql-\u003ecreateDatabase('test_db');\r\n\r\n// Create User and assign to Database\r\n$jsql-\u003ecreateUser('admin', 'root', 'test_db');\r\n\r\n// Select Current Database\r\n$jsql-\u003eselect_db('test_db');\r\n\r\n// Create Table\r\n$sql = \"CREATE TABLE `#__articles` (\r\n  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,\r\n  `article_id` INT UNSIGNED NOT NULL DEFAULT 0,\r\n  `cat_id` INT UNSIGNED NOT NULL DEFAULT 0,\r\n  `user_id` INT UNSIGNED NOT NULL DEFAULT 0,\r\n  `lang_id` INT UNSIGNED NOT NULL DEFAULT 0,\r\n  `title` VARCHAR(200) NOT NULL,\r\n  `content` TEXT NULL COMPRESSED,\r\n  `created` DATETIME NULL DEFAULT CURRENT_TIMESTAMP(),\r\n  `updated` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP()\r\n);\";\r\n\r\n$jsql-\u003esetSQLQuery($sql);\r\n$jsql-\u003eexecute();\r\n\r\n// Insert Data\r\n$query-\u003esetSQLQuery(\"INSERT INTO #__articles (article_id, cat_id, user_id, lang_id, title, content) VALUES \r\n(1, 1, 1, 1, 'Title 1', 'Test Content 1'),\r\n(1, 1, 1, 2, 'Title 2', 'Test Content 2'),\r\n(2, 2, 1, 1, 'Title 3', 'Test Content 3'),\r\n(3, 3, 1, 1, 'Title 4', 'Test Content 4'),\r\n(3, 1, 1, 2, 'Title 5', 'Test Content 5');\r\n\");\r\n$query-\u003eexecute();\r\n\r\n$query = \"SELECT article_id AS aid, title, content AS doc FROM #__articles WHERE user_id = \".$my-\u003eid.\" AND lang_id = 1 ORDER BY created DESC LIMIT 10\";\r\n$jsql-\u003esetSQLQuery($query);\r\n$jsql-\u003eexecute();\r\n$data = $jsql-\u003egetResults();\r\n\r\n// Close all open database resources\r\n$jsql-\u003eclose();\r\n\r\nprint_r($data);\r\n?\u003e\r\n```\r\n\r\n### 📑 **Alternative way to create a table**\r\n\r\n```php\r\n\r\n// Direct way to create a table and its structure.\r\n$schema = [\r\n  'id' =\u003e 'INT NOT NULL AUTO_INCREMENT PRIMARY KEY',\r\n  'article_id' =\u003e 'INT UNSIGNED NOT NULL DEFAULT 0',\r\n  'cat_id' =\u003e 'INT UNSIGNED NOT NULL DEFAULT 0',\r\n  'user_id' =\u003e 'INT UNSIGNED NOT NULL DEFAULT 0',\r\n  'lang_id' =\u003e 'INT UNSIGNED NOT NULL DEFAULT 0',\r\n  'title' =\u003e 'VARCHAR(200) NOT NULL',\r\n  'content' =\u003e ' TEXT NULL COMPRESSED',\r\n  'created' =\u003e ' DATETIME NULL DEFAULT CURRENT_TIMESTAMP()',\r\n  'updated' =\u003e 'DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP()'\r\n];\r\n\r\n$jsql-\u003ecreateTable('#__articles', $schema);\r\n\r\n```\r\n\r\n✏️ **See more examples on the official website!**  \r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexsoft-software%2Fjsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexsoft-software%2Fjsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexsoft-software%2Fjsql/lists"}