Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamwulf/json-to-mysql
Easily take any JSON object and create+insert it into a mysql table built from its structure. Also search, update, index, and validate tables with JSON.
https://github.com/adamwulf/json-to-mysql
Last synced: 3 days ago
JSON representation
Easily take any JSON object and create+insert it into a mysql table built from its structure. Also search, update, index, and validate tables with JSON.
- Host: GitHub
- URL: https://github.com/adamwulf/json-to-mysql
- Owner: adamwulf
- License: other
- Created: 2013-10-18T08:36:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-04-11T05:39:50.000Z (over 3 years ago)
- Last Synced: 2024-05-01T12:30:01.419Z (7 months ago)
- Language: PHP
- Size: 54.7 KB
- Stars: 136
- Watchers: 18
- Forks: 64
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
json-to-mysql
=============Easily take any JSON object and create+insert it into a mysql table built from its structure. Also search, update, index, and validate tables with JSON.
```
include("config.php");
include("include.classloader.php");$classLoader->addToClasspath(ROOT);
$mysql = new MySQLConn(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASS);
$db = new JSONtoMYSQL($mysql);
// create some json
$obj = json_decode('{"id":4,"name" : "asfd"}');// save it to a table
$db->save($obj, "brandnewtable");// SELECT * from brandnewtable WHERE id = 4
$obj = $db->table("brandnewtable")->find(["id" => 4]);
print_r($obj);
// SELECT * FROM brandnewtable WHERE id > 4 ORDER BY name DESC
$obj = $db->table("brandnewtable")->find(["id" => 4], ["id" => ">"], ["name DESC"]);
print_r($obj);
// SELECT * FROM brandnewtable WHERE id IN (4, 5, 6, 7)
$obj = $db->table("brandnewtable")->find(["id" => [4, 5, 6, 7]]);
print_r($obj);
```
## Support the project
Has json-to-mysql saved you some time? Become a [Github Sponsor](https://github.com/sponsors/adamwulf) and buy me a coffee ☕️ 😄