Skip to content

Commit

Permalink
Merge pull request #9 from petrabarus/master
Browse files Browse the repository at this point in the history
[WIP] Rewriting the query
  • Loading branch information
petrabarus committed Jan 5, 2016
2 parents 6f4ad3c + 8dc97e3 commit d062135
Show file tree
Hide file tree
Showing 30 changed files with 5,187 additions and 867 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.0.0] - 2015-12-30
### Added
- Support `ActiveDataProvider` and `Pagination`
- More unit tests.
### Changed
- A lot of changes from last release. _Sorry for that_ :)
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,84 @@

This is a DynamoDB extension for Yii2


[![Latest Stable Version](https://poser.pugx.org/urbanindo/yii2-dynamodb/v/stable.svg)](https://packagist.org/packages/urbanindo/yii2-dynamodb)
[![Total Downloads](https://poser.pugx.org/urbanindo/yii2-dynamodb/downloads.svg)](https://packagist.org/packages/urbanindo/yii2-dynamodb)
[![Latest Unstable Version](https://poser.pugx.org/urbanindo/yii2-dynamodb/v/unstable.svg)](https://packagist.org/packages/urbanindo/yii2-dynamodb)
[![Build Status](https://travis-ci.org/urbanindo/yii2-dynamodb.svg)](https://travis-ci.org/urbanindo/yii2-dynamodb)

## Requirement

This extension requires
- PHP 5.4
- Yii2
- AWS PHP SDK 2.8

## Installation

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist urbanindo/yii2-dynamodb "*"
```

or add

```
"urbanindo/yii2-dynamodb": "*"
```

to the require section of your `composer.json` file.

## Setting Up

After the installation, sets the `dynamodb` component in the config.

```php
return [
// ...
'components' => [
// ...
'dynamodb' => [
'class' => 'UrbanIndo\Yii2\DynamoDb\Connection',
'config' => [
//This is the config used for Aws\DynamoDb\DynamoDbClient::factory()
//See http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-dynamodb.html#factory-method
'credentials' => [
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
],
'region' => 'ap-southeast-1',
]
]
],
];
```

## Limitation

Because DynamoDB have different behavior from MySQL, there are several
limitations or behavior change applied. There are several method to get data from
DynamoDB: __GetItem__, __BatchGetItem__, __Scan__, and __Query__.

1. We have tried to implement automatic method to acquire model from Query. You should
assign method explicitly if you want to force the method to use.
2. Not yet support attribute name aliasing (In MySQL known as field aliasing).
3. When using __Query__ method, where condition just support filter by key attributes.
In next roll out we will add filtering with non key attributes.
4. To make pagination, we forcedly using __Query__ method when WHERE condition is set.
Because if you use filtering with non key attribute, it is possible the model result(s)
will less than desired limit value.
5. `indexBy` and `orderBy` cannot use with attribute string value or callable parameter.
This will use as string value and assign to `IndexName` parameter in DynamoDB. To
use sorting, this will forcedly use __QUERY__ method and `orderBy` parameter should be
either `['myIndex' => 'ASC']` or `['myIndex', 'DESC']` and key condition expression
should be defined.
6. Not support NULL and any kind of set attribute type.
7. Not support attribute aliasing belong to Reserve Keywords, which means all attributes
do not using any [Reserve Keywords](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html).
8. When use LinkPager, do not forget use ActiveDataProvider from this package. When
the pagination pass into any kind of Widget View, several components maybe unsupported
like _SerialColumn_, unnecessary total items in summary, and sorting.
6 changes: 6 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
</finally>
</trycatch>
</target>
<target name="phpcs">
<exec executable="${basedir}/vendor/bin/phpcs" failonerror="true">
<arg value="--standard=${basedir}/ruleset.xml"/>
<arg value="src"/>
</exec>
</target>
<target name="prepare">
<mkdir dir="${basedir}/dynamodb"/>
<get dest="dynamodb/ant-contrib.jar" >
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
"require-dev": {
"phpunit/phpunit": "4.6.*",
"phpunit/dbunit": ">=1.2",
"phpunit/php-code-coverage": "2.2.4",
"fzaninotto/faker": "dev-master",
"flow/jsonpath": "dev-master"
"flow/jsonpath": "dev-master",
"yiisoft/yii2-coding-standards": "*",
"squizlabs/php_codesniffer": "2.*"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit d062135

Please sign in to comment.