|Classes of Yorman||>||Maricuto PHP Flat File Database||>||README.md||>||Download|
<h1 align="center" class="vicinity rich-diff-level-zero"> MaricutoDB | PHP Flat File Database Manager. </h1>
<p align="center"> <img src="http://maricuto.xyz/default/public/html_base/img/maricutodb/logo.svg" title="MaricutoDB php flat file database manager" style="width: 200px" alt="MaricutoDB php flat file database manager"> </p>
<p align="center"> <img src="https://img.shields.io/badge/contributor-Yorman%20Maricuto-blue.svg?longCache=true&style=flat-square" alt=" "> <img src="https://img.shields.io/badge/Files-JSON-green.svg?longCache=true&style=flat-square" alt=" "> <img src="https://img.shields.io/badge/System-CRUD-blue.svg?longCache=true&style=flat-square" alt=" "> <img src="https://img.shields.io/badge/Security-password__hash-blue.svg?longCache=true&style=flat-square" alt=" "> <img src="https://img.shields.io/badge/has-paginator%20system-orange.svg?longCache=true&style=flat-square" alt=" "> <img src="https://img.shields.io/badge/has-search--engine-orange.svg?longCache=true&style=flat-square" alt=" "> </p>
<p align="center"> Copyright (c) | Yorman Maricuto 2018 | <a href="mailto:firstname.lastname@example.org">
</a> <br> <a href="http://maricuto.xyz">author website of the project</a> </p>
Table of contents
1) <a href="#getting-started">Getting Started</a><br> 2) <a href="#maricutodb--features">Features</a><br> 3) <a href="#how-to-use">How to use | create data</a><br> 4) <a href="#insert-more-data-in-a-created-table">Insert data</a><br> 5) <a href="#getting-created-data">Getting created data</a><br> 6) <a href="#getting-a-common-item-from-many-tables">Getting a common item from many tables</a><br> 7) <a href="#getting-a-common-item-from-many-tables">Getting a unknown table id</a><br> 8) <a href="#getting-an-unknow-item-id">Getting a unknown table id</a><br> 9) <a href="#verifying-data-and-passwords">Verifying data and passwords</a><br> 10) <a href="#paginator">Paginator</a><br> 11) <a href="#search-engine">Search Engine</a><br> 12) <a href="#update-database">Update Database</a><br> 13) <a href="#backups">Backups</a><br> 14) <a href="#delete-data">Delete data</a><br> 15) <a href="#restore-a-backup">Restore a backup</a><br> 16) <a href="#license">License</a><br>
MaricutoDB it's a lightweight database manager with flexibility and easy to use. allow create, read, update and delete: database, tables, columns and rows that are saved as a JSON file (CRUD).
To start using the Database only require:
You can download the latest and clean version here: > http://maricuto.xyz/maricutodb
MaricutoDB | Features
Create a Database Easily.
New Feataures | added at 2018/09/30
Now MaricutoDB has a simple search engine.
> This can overload the server if there are many tables
The paginator function eliminate the reading of all files to get contents and only read that will appear per page. This make MaricutoDB a good database manager for many projects like blogs, portfolios, gallery images webpage and more.
How to use
Creating a Database
You only need one line to create a database and insert data to it, setting four variables.
> MaricutoDB::Create( $db_name, $table_id, $item_name, $item_content );
> This method can create new data but it's not to update content tables.
| Variable | description | |---------------|--------------| | $db_name | to create DB or if exist point to it. | | $table_id | to create an table_id or if exist point to it. | | $item_name | to create a item name in the table named above. | | $item_content | insert content in the named item name above. |
Insert more data in a created table
you can add more data to the same table, you only need to be secure to point to the same ID. in this case (above) 'user_n_1' and in the same DB ('UsersDB').
Insert and secured a passwords
To make it, you only need to set a fifth argument to TRUE
Getting created data
To simply get a table and show an item of it, just use:
> $Get = Database::Table( $db_name, $table_id );
| Variable | description | |---------------|--------------| | $db_name | a existing or created DB to point | | $table_id | an existing table in the named DB above. |
Getting a common item from many tables
This function can be useful when we try to get a common item from each DB table. If we have something like 10 products in a DB called 'books', each book represent a _Database Table_ and we can get the data tables without calling one by one and without knowledge of each id table.
> This method only need one argument, the _db_name_.
> $GetData = Database::GetData( $existing_db_name );
Now you can give a layout and style to all data that we are getting from the DB
> The Database will give us a stdClass Object so, we need to make a foreach to output the data.
> for each row we need to use the method _Generate::Row( $GetData, $ItemName, $error = 'N/A' );_
| Variable | description | |---------------|--------------| | $GetData | the variable we have obtained with the method GetData above | | $ItemName | an existing ItemName in the table. | | $error | if the item name don't exists the method will output "N/A" by default you can set whatever string you want |
> _Generate::Row_ method will works like the $GetData->ItemName to show specific items. But this method can verify and ouput personalized errors if the item don't exist.
If we have a Database with three books and their authors the code above will ouput:
| Book | Author | | ------------- | ------------- | | The Breathing Method | Stephen King | | Hickory Dickory Dock | Agatha Christie | | The Hound of the Baskervilles | Conan Doyle |
Getting an unknow item id
MaricutoDB has the method to generate 'RandomString' and use like a RANDOMID to create tables. This is to make the table creations easily, also we don't need to know the TABLE ID to Get the Data.
> $RandomString = Generate::RandomString();
Let's create a database table with a random id.
Getting the random ID
The code above will create a new table into the database called 'UsersDB' with a random id. We can get the id from another known unique data like a nickname (username), using the OutputId method.
> $id = Database::OutputId( $db_name, $item_name, $content );
| Variable | description | |---------------|--------------| | $db_name | An existing DB | | $ItemName | an existing ItemName in each table. | | $content | a unique content like username, nickname, ID, or something like that |
Verifying data and passwords
If we have a panel to login and we need to verify the data that a user send through form with method POST. MaricutoDB has a method for it. First we need to make a PHP code that will be excuted only when users submit a form.
MaricutoDB has a simple paginator to slice data by pages:
MaricutoDB has a simple search engine that can be use to search coincidences when a input is submitted to search something. This can overload the server if we are trying to search in many tables, also we can search something without overload the system in 3000-6000 tables about depending on the JSON table file size too.
> This is in development now, but also can be useful.
How to implement the search engine.
First we need to create a new page called 'searching' or whatever you want, this is the page where MaricutoDB will make the queries and show the results. (www.example.com/searching)
We need to use the Method 'GetData'. You have some searching database types. You need to select one of them.
> 1) If you want to search in all DBs just leave GetData method without setting any variable
> 2) If you want to search in a specific DB, set the firts argument to that DB name
> 3) If you want to search in two or more DBs set an array into the argument.
> 4) If you want to search in all DBs but excluding some of them:
Now we need to show the data with a foreach sentence like above codes when we were trying to show many tables with the method GetData (Getting a common item from many tables).
The difference here is that only will appear when a '$_GET' variable is set, for example '$_GET['query']'. This variable will be set when the user request something in the search engine.
MaricutoDB will search something in each table, if there is a coincidence with the words sent, it will execute with the layout and style that you need to output to the user.
Let's create the input form for the search engine. This can be place whatever you want. You need to place where the form will make the searching in the action attr, in this case in 'searching' page.
Simply use this method:
Restore a backup
This project is licensed under the MIT License. https://github.com/Yerikmiller/maricutodb/blob/master/LICENSE
Latest Documentation versions visit: