Download the PHP package kappa/deaw without Composer
On this page you can find all versions of the php package kappa/deaw. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package deaw
Short Description Tiny wrapper for better and more comfortable works with Dibi
License MIT
Homepage https://github.com/Kappa-org/Deaw
Informations about the package deaw
Kappa\Deaw
Tiny wrapper for better and more comfortable works with dibi
Content
- Requirements
- Installation
- How to use
- Fetches
- Execute
- Transactions
- Query objects
- Development
- Tests
Requirements
Full list of dependencies you can get from Composer config file
Installation
The best way to install Kappa\Deaw is using Composer
Before your first usage you must have registered dibi
with required settings.
When you have dibi
registered you can add Kappa\Deaw
extension without any extra configuration (all configuration will be used from dibi
package).
How to use
The basic principe of this package is combine domain queries(cz)
and dibi
way. This package provides a query objects which can be used for fetching or
executing queries and which is distributed into custom classes.
Usage this package is very easy. Kappa\Deaw
provides one base class Kappa\Deaw\DataAccess
for make works
with dibi
more comfortable. With this class you can make all fetches, executes and
you can work with transactions.
Firstly, you can inject this class into your model
prepare the basic fetch query object which must implements
\Kappa\Deaw\Query\Queryable
interface or for easy query objects you can use abstract
class \Kappa\Deaw\Query\QueryObject
and now we can combine into model
and it's all!
Fetches
The basic fetch principe is explained above. You can use three methods for fetching data.
fetch
- for fetch all records (alternative tofetchAll
fromdibi
)fetchOne
- for fetch only one record (alternative tofetch
fromdibi
)fetchSingle
- for fetch single value (alternative tofetchSingle
fromdibi
)
Execute
You can also run executable query object for insert, update or remove data. For example:
and model
Transactions
Also, you can use very easy transactions wrapper for typical dibi
transactions.
We use AddNewAdminUser
query object from previous example for example:
And of course you use savepoints (when is supported) as nested transactions
Query objects
The basic query object provide postFetch
method which is called after each fetch.
This method can be used for parsing data before return or for somethings else...
TIP: This method can be used for parsing to-many relations from string representation into array, for example:
SQL:
and results will be
Development
Tests
When you can run test you must crate own config files. Please copy file
tests/config/config.sample.neon
, rename to config.neon
(remove sample
word) and update credentials in this file. Same do with
tests/config/database.sample.ini
And now you can run test ./vendor/bin/tests -c ./tests/php-unix.ini ./tests