Following steps are necessary to get this module working, considering a zf2-skeleton or very similar application:, (*3)
-
Configure the data service:, (*6)
'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:, (*7)
// Optional parameters
$parameters = array(':param' => 'value');
$exampleDataService->select('all');
-
Search:, (*8)
// 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:, (*9)
$exampleDataService->bind($form);
$form->setData($data);
if ($this->form->isValid()) {
// valid data were stored
}
-
Manual save:, (*10)
$exampleDataService->exchangeArray($row); // update if $row['id'] is not empty
-
Validate data array: throws exception on invalid, (*11)
$exampleDataService->validate($data);
-
Increment column in one query:, (*12)
$where = array('id' => $id);
$exampleDataService->increment('count', $where);
-
Delete:, (*13)
$where = array('column=?' => 'value');
$exampleDataService->delete($where);
-
Return related data rows:, (*14)
$relatedDataService->owned($exampleDataService, $id);
-
Set owner id to the related row:, (*15)
$exampleDataService->own($relatedRow, $id);
-
Be sure you have configured ~/.my.cnf
for the mysqladmin
command, (*18)
-
Clone this repository, (*19)
-
Configure the db in the test/resources/config.local.php.dist
and delete the .dist
extension., (*20)
-
Run phing update
, (*21)
Now your development environment is set., (*22)
-
Open project in (NetBeans) IDE, (*23)
-
To check module integration with the skeleton application open following directory via web browser:, (*24)
._test/ZendSkeletonApplication/public/
, (*25)
e.g. http://localhost/WebinoData/._test/ZendSkeletonApplication/public/, (*26)
-
Integration test resources are in directory: test/resources
, (*27)
NOTE: Module example config is also used for integration testing., (*28)
Please, if you are interested in this Zend Framework module report any issues and don't hesitate to contribute., (*32)