https://github.com/kroyxt/datbazo
DatBazo(Datuma Bazo, Database in Esperanto) is a SQL-query constructor using PDO.
https://github.com/kroyxt/datbazo
database esperanto php
Last synced: 6 months ago
JSON representation
DatBazo(Datuma Bazo, Database in Esperanto) is a SQL-query constructor using PDO.
- Host: GitHub
- URL: https://github.com/kroyxt/datbazo
- Owner: kroyxt
- License: mit
- Created: 2019-04-03T19:11:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-15T20:24:59.000Z (about 7 years ago)
- Last Synced: 2025-08-16T14:48:51.236Z (11 months ago)
- Topics: database, esperanto, php
- Language: PHP
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.md
Awesome Lists containing this project
README
# DatBazo
DatBazo(Datuma Bazo, Database in Esperanto) is a SQL-query constructor using PDO. is a small library with which you can quickly create queries to the database using the "Prepare" and "Execute" methods of PDO to avoid sql injections.
## Table of contents
1. [Dependencies](#Dependencies)
2. [Install](#Install)
3. [Getting started](#Getting-started)
4. [Methods](#Methods)
5. [Author](#Author)
6. [License](#License)
## Dependencies
This package requires PHP 7 or higher.
## Install
### via composer
```console
composer require kroyxlab/datbazo
```
### Copy repository
Copy the direct repository to your project and require the class.
```php
require_once 'proyect_directory/datbazo/src/DatBazo.php';
use kroyxlab\datbazo\DatBazo as DatBazo;
```
## Getting started
Modify the KLPdo.ini file located in the folder `vendor/kroyxlab/datbazo/src/DBconfig.ini` and modify the values to configure the connection to the database.
```ini
[databazo]
db_driver = Mysql || sqlite3 || pgsql
db_host = Host_name
db_port = Port
db_name = Database_name
db_user = user
db_password = password
db_charset = UTF8
```
If everything is configured correctly, you can start using the library.
```php
require_once "vendor/autoload.php";
use kroyxlab\datbazo\DatBazo as DatBazo;
// instantiate the DatBazo class
$productos = new DatBazo;
// Create an SQL statement using the methods of the KLPdo class
$products->select(['products'=>'name, price'])
->where(['price'=>['>=', 12.5]])
->order('price')
->execute();
// Set the type of fetch you want.
$products->fetch('assoc');
// Use the Method -> render (); to output and format the result of the sql query
$products->render(function($product){
return "
The name of the product is {$product['name']} and the price is {$product['price']}
";
});
// Or use a foreach loop using the fetch method
foreach($products->fecth('obj') as $product){
echo "
The name of the product is $product->name and the price is $product->price
"
}
```
## Methods
The methods of the DatBazo class help to create an SQL statement which will be executed through the `prepare` and `execute` methods of Pdo to avoid SQL injections.
### **List of methods:**
* [Select()](./docs/en/select.md)
* [join()](./docs/en/join.md)
* [Insert()](./docs/en/insert.md)
* [Where()](./docs/en/where.md)
* [Update()](./docs/en/update.md)
* [Delete()](./docs/en/delete.md)
* [Limit()](./docs/en/limit.md)
* [Offset()](./docs/en/offset.md)
* [Group()](./docs/en/group.md)
* [Order()](./docs/en/order.md)
* [Execute()](./docs/en/execute.md)
* [Fetch()](./docs/en/fetch.md)
* [Render()](./docs/en/render.md)
## **Author**
* **Kristian Soto (KroyxLab)** - [Github](https://github.com/KroyxLab) | [Gitlab](https://gitlab.com/KroyxLab)
## **License**
This project is licensed under the MIT License - see the [MIT.md](license.md) file for details