Download the PHP package midorikocak/nanodb without Composer
On this page you can find all versions of the php package midorikocak/nanodb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download midorikocak/nanodb
More information about midorikocak/nanodb
Files in midorikocak/nanodb
Package nanodb
Short Description Nano DB is a tiny php library that allows you to define easily usable repositories.
License MIT
Homepage https://github.com/midorikocak/nanodb
Informations about the package nanodb
Nano DB
Nano DB is a tiny php library that allows you to define easily usable repositories.
There are 3 handy classes and 1 example in this library. Let's start with basics:
Requirements
Strictly requires PHP 7.4.
Install
Via Composer
Usage
Database
To use database library, simple inject it with pdo.
Alternatively, if you want to use a query object, you can inject it as well.
Operations are chained.
Select
If found, returns the data you need. If nothing found, empty array is returned.
Example output:
Order by
To order results use the orderBy($fieldName)
method.
Offset and Limit
To limit and offset results use the limit($limit)
and offset($offset)
methods.
Insert
Insert using an array of data. Validation is your responsibility.
Update
Insert using an array of data. Again validation is your responsibility. If id does not exist, throws exception.
Delete
Returns affected rows. If id does not exist, throws exception.
RepositoryInterface
The repository interface is the interface of repositories.
If you want to use arrays to interact with your database, you can use the array repository.
Here $schema
array is a simple optional array for Array validator, checked on every input with data. You can override it by extending ArrayValidator
class.
Class Repositories
Let's say you have a simple user class.
You can create a Users
repository, by implementing the RepositoryInterface
.
Motivation and Warning
Mostly educational purposes. Please use at your own risk.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Midori Kocak
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of nanodb with dependencies
ext-json Version *
ext-pdo Version *
midorikocak/arraytools Version ^1.0.2
midorikocak/querymaker Version ^1.4.3
phpunit/php-token-stream Version ^4.0