webino / webino-data
Modular Data service over Zend Db
Installs: 14 095
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- ext-mbstring: *
- webino/webino-i18n-sanitize-lib: dev-develop
- webino/zend-db: ~2.7.2
- zendframework/zend-cache: 2.*
- zendframework/zend-eventmanager: 2.*
- zendframework/zend-filter: 2.*
- zendframework/zend-inputfilter: 2.*
- zendframework/zend-paginator: 2.*
- zendframework/zend-servicemanager: 2.*
- zendframework/zend-stdlib: 2.*
Suggests
- webino/webino-debug: Debugger support
- zendframework/zend-mvc: To use as a Zend Framework module
This package is auto-updated.
Last update: 2024-10-22 10:54:32 UTC
README
Very early alpha version
Provides lightweight data service.
Features
- Configurable sql select
- Advanced search
- Input filter
- Bind to form [NEED REFACTOR]
- Auto column:
datetime_add
[INCOMPLETE]datetime_update
Setup
Following steps are necessary to get this module working, considering a zf2-skeleton or very similar application:
- Run
php composer.phar require webino/webino-data:dev-develop
- Add
WebinoData
to the enabled modules list
QuickStart
Better to check following
`config/webinodataexample.local.php.dist`
`test/resources/IndexController.php`
It needs update
-
Configure the data service:
'di' => array( 'instance' => array( 'exampleTable' => array( 'parameters' => array( 'table' => 'example', 'adapter' => 'defaultDb', ), ), 'exampleDataService' => array( 'parameters' => array( 'tableGateway' => 'exampleTable', 'config' => array( 'searchIn' => array( // search only defined columns 'title', ), 'select' => array( // list of available selects 'all' => array( ), 'example' => array( 'columns' => array( array( '*', new \Zend\Db\Sql\Expression('(column/10) as rating'), ), ), 'where' => array( array('column!=:param') ), 'limit' => 100, 'order' => array( new \Zend\Db\Sql\Expression('RAND()'), ), ), ), 'input_filter' => array( 'column' => array( 'name' => 'column', 'required' => false, 'validators' => array( array( 'name' => 'digits', 'options' => array( ), ), ), 'filters' => array( array( 'name' => 'int', 'name' => 'Example\Filter', ), ), ), ), ), ), ), ), ),
-
Select array of rows:
// Optional parameters $parameters = array(':param' => 'value'); $exampleDataService->select('all');
-
Search:
// Optional parameters $parameters = array(':param' => 'value'); // Return just like term, but ignore inferior chars $exampleDataService->selectJust('search', $term, $parameters); // Return at least something like term $exampleDataService->selectLike('search', $term, $parameters);
-
Bind form:
$exampleDataService->bind($form); $form->setData($data); if ($this->form->isValid()) { // valid data were stored }
-
Manual save:
$exampleDataService->exchangeArray($row); // update if $row['id'] is not empty
-
Validate data array: throws exception on invalid
$exampleDataService->validate($data);
-
Increment column in one query:
$where = array('id' => $id); $exampleDataService->increment('count', $where);
-
Delete:
$where = array('column=?' => 'value'); $exampleDataService->delete($where);
-
Return related data rows:
$relatedDataService->owned($exampleDataService, $id);
-
Set owner id to the related row:
$exampleDataService->own($relatedRow, $id);
Develop
Requirements
- Linux (recommended)
- NetBeans (optional)
- Phing
- PHPUnit
- Selenium
- Web browser
Setup
-
Be sure you have configured
~/.my.cnf
for themysqladmin
command -
Clone this repository
-
Configure the db in the
test/resources/config.local.php.dist
and delete the.dist
extension. -
Run
phing update
Now your development environment is set.
-
Open project in (NetBeans) IDE
-
To check module integration with the skeleton application open following directory via web browser:
._test/ZendSkeletonApplication/public/
e.g. [http://localhost/WebinoData/._test/ZendSkeletonApplication/public/](http://localhost/WebinoData/._test/ZendSkeletonApplication/public/)
-
Integration test resources are in directory:
test/resources
NOTE: Module example config is also used for integration testing.
Testing
-
Run
phpunit
in the test directory -
Run
phing test
in the module directory to run the tests and code insightsNOTE: To run the code insights there are some tool requirements.
Todo
- Shared relations.
- Manual insert/update.
- Relation handle id array (return related rows for multiple ids).
Addendum
Please, if you are interested in this Zend Framework module report any issues and don't hesitate to contribute.