Skip to content

Commit

Permalink
Release version 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FaaPz committed Jul 25, 2015
1 parent 1a2d889 commit 99e5032
Show file tree
Hide file tree
Showing 33 changed files with 2,424 additions and 2 deletions.
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ---------------------------
# --- OSX Generated Files ---
# ---------------------------

.DS_Store
.AppleDouble
.LSOverride

# --- Icon Must End With Two \r ---
Icon


# --- Thumbnails ---
._*

# --- Files That Might Appear On External Disk ---
.Spotlight-V100
.Trashes

# --- Directories Potentially Created On Remote AFP Share ---
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# ---------------------------
# --- WIN Generated Files ---
# ---------------------------

# --- Windows Image File Caches ---
Thumbs.db
ehthumbs.db

# --- Folder Config File ---
Desktop.ini

# --- Recycle Bin Used On File Shares ---
$RECYCLE.BIN/

# --- Windows Installer Files ---
*.cab
*.msi
*.msm
*.msp

# ---------------------------
# ---- Development Files ----
# ---------------------------

composer.lock
composer.phar
vendor/
.idea/
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### Changelog

##### v1.6.1
+ Updated documentation, see [docs](https://github.com/FaaPz/Slim-PDO/blob/master/docs) directory
+ Updated query builder with:
- Added `havingCount()` method
- Added `havingMax()` method
- Added `havingMin()` method
- Added `havingAvg()` method
- Added `havingSum()` method

##### v1.6.0
+ Added documentation, see [docs](https://github.com/FaaPz/Slim-PDO/blob/master/docs) directory
+ Removed `AggregateClause` class (stupid mistake, aggregates are not clauses)
+ Updated query builder with:
- Added `whereLike()` method
- Added `orWhereLike()` method
- Added `whereNotLike()` method
- Added `orWhereNotLike()` method
+ Updated `SelectStatement` class with:
- Added aggregate methods `count()`, `distinctCount()`, `max()`, `min()`, `avg()` and `sum()`

##### v1.5.0
+ Updated query builder with:
- Added `having()` method
- Added `orHaving()` method
- Added `distinct()` method
- Added `count()` method
- Added `distinctCount()` method
- Added `max()` method
- Added `min()` method
- Added `avg()` method
- Added `sum()` method

##### v1.4.0
+ Updated query builder with:
- Added `whereBetween()` method
- Added `orWhereBetween()` method
- Added `whereNotBetween()` method
- Added `orWhereNotBetween()` method
- Added `whereIn()` method
- Added `orWhereIn()` method
- Added `whereNotIn()` method
- Added `orWhereNotIn()` method
- Added `whereNull()` method
- Added `orWhereNull()` method
- Added `whereNotNull()` method
- Added `orWhereNotNull()` method

##### v1.3.0
+ Updated query builder with:
- Added `where()` method
- Added `orWhere()` method
- Added `join()` method
- Added `leftJoin()` method
- Added `rightJoin()` method
- Added `fullJoin()` method

##### v1.2.0
+ Updated query builder with:
- Added `groupBy()` method
- Added `orderBy()` method
- Added `limit()` method
- Added `offset()` method

##### v1.1.0
+ Added query builder

##### v1.0.0
+ First release version
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

SOFTWARE.
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,84 @@
# Slim-PDO

PDO database library for Slim Framework

### Installation

Use [Composer](https://getcomposer.org/)

```json
"require": {
"slim/pdo": "~1.7"
}
```

### Usage

Simple example selecting all data from `users` table.

```php
require_once('vendor/autoload.php');

$dsn = 'mysql:host=your_db_host;dbname=your_db_name;charset=utf8';
$usr = 'your_db_username';
$pwd = 'your_db_password';

$pdo = new \Slim\PDO\Database( $dsn , $usr , $pwd );

$qry = $pdo->prepare("SELECT * FROM users");
$qry->execute();

try
{
var_dump( $qry->fetchAll() );
}
catch( \PDOException $e )
{
exit( $e->getMessage() );
}
```

Examples selecting, inserting, updating and deleting data from or into `users` table.

```php
// SELECT * FROM users WHERE id = ?
$selectStatement = $pdo->select()
->from('users')
->where('id', '=', 1234);

$stmt = $selectStatement->execute();
$data = $stmt->fetchAll();

// INSERT INTO users ( id , usr , pwd ) VALUES ( ? , ? , ? )
$insertStatement = $pdo->insert(array('id', 'usr', 'pwd'))
->into('users')
->values(array(1234, 'your_username', 'your_password'));

$insertId = $insertStatement->execute();

// UPDATE users SET pwd = ? WHERE id = ?
$updateStatement = $pdo->update(array('pwd' => 'your_new_password'))
->table('users')
->where('id', '=', 1234);

$affectedRows = $updateStatement->execute();

// DELETE FROM users WHERE id = ?
$deleteStatement = $pdo->delete()
->from('users')
->where('id', '=', 1234);

$affectedRows = $deleteStatement->execute();
```

### Documentation (WIP)

See [DOCUMENTATION](https://github.com/FaaPz/Slim-PDO/blob/master/docs/README.md)

### Changelog

See [CHANGELOG](https://github.com/FaaPz/Slim-PDO/blob/master/CHANGELOG.md)

### License

See [LICENSE](https://github.com/FaaPz/Slim-PDO/blob/master/LICENSE)
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "slim/pdo",
"description": "PDO database library for Slim Framework",
"version": "1.7.0",
"type": "library",
"keywords": ["pdo", "database", "slim", "framework"],
"homepage": "https://github.com/FaaPz/Slim-PDO",
"license": "MIT",
"authors": [
{
"name": "Fabian de Laender",
"email": "[email protected]",
"homepage": "http://faapz.nl",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/FaaPz/Slim-PDO/issues"
},
"require": {
"php": ">=5.3.0",
"ext-pdo": "*"
},
"autoload": {
"psr-4": {
"Slim\\PDO\\": "src/PDO/"
}
}
}
31 changes: 31 additions & 0 deletions docs/AGGREGATES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### Aggregates

##### Methods

+ `count()`
+ `distinctCount()`
+ `max()`
+ `min()`
+ `avg()`
+ `sum()`

> Used only in [SELECT](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/SELECT.md) statements.
##### Examples

```php
// ... COUNT( * )
$selectStatement->count();

// ... COUNT( votes ) AS all_votes
$selectStatement->count('votes', 'all_votes');

// ... COUNT( DISTINCT customer_id )
$selectStatement->distinctCount('customer_id');

// ... MIN|MAX( salary ) , AVG( price ) , SUM( votes )
$selectStatement->min('salary');
$selectStatement->max('salary');
$selectStatement->avg('price');
$selectStatement->sum('votes');
```
14 changes: 14 additions & 0 deletions docs/Clause/GROUP_BY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### GROUP BY clause

##### Methods

+ `groupBy()`

> Used only in [SELECT](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/SELECT.md) statements.
##### Examples of grouping

```php
// ... GROUP BY f_name
$selectStatement->groupBy('f_name');
```
33 changes: 33 additions & 0 deletions docs/Clause/HAVING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### HAVING clause

##### Methods

+ `having()`
+ `orHaving()`
+ `havingCount()`
+ `havingMax()`
+ `havingMin()`
+ `havingAvg()`
+ `havingSum()`

> Used only in [SELECT](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/SELECT.md) statements.
##### Examples

```php
// ... HAVING MIN( price ) > ? OR MAX( price ) < ?
$selectStatement->having('MIN( price )', '>', 125)->orHaving('MAX( price )', '<', 250);

// ... HAVING COUNT( * ) > ?
$selectStatement->havingCount('*', '>', 1234);

// ... HAVING MIN|MAX( salary ) > ?
$selectStatement->havingMin('salary', '>', 25000);
$selectStatement->havingMax('salary', '<', 50000);

// ... HAVING AVG( price ) < ?
$selectStatement->havingAvg('price', '<', 12.5);

// ... HAVING SUM( votes ) > ?
$selectStatement->havingSum('votes', '>', 25);
```
27 changes: 27 additions & 0 deletions docs/Clause/JOIN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### JOIN clause

##### Methods

+ `join()`
+ `leftJoin()`
+ `rightJoin()`
+ `fullJoin()`

> Used only in [SELECT](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/SELECT.md) statements.
##### Examples

```php
// ... INNER JOIN orders ON customers.id = orders.customer_id
$selectStatement->join('orders', 'customers.id', '=', 'orders.customer_id');
$selectStatement->join('orders', 'customers.id', '=', 'orders.customer_id', 'INNER');

// ... LEFT OUTER JOIN orders ON customers.id = orders.customer_id
$selectStatement->leftJoin('orders', 'customers.id', '=', 'orders.customer_id');

// ... RIGHT OUTER JOIN orders ON customers.id = orders.customer_id
$selectStatement->rightJoin('orders', 'customers.id', '=', 'orders.customer_id');

// ... FULL OUTER JOIN orders ON customers.id = orders.customer_id
$selectStatement->fullJoin('orders', 'customers.id', '=', 'orders.customer_id');
```
14 changes: 14 additions & 0 deletions docs/Clause/LIMIT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### LIMIT clause

##### Methods

+ `limit()`

> Used in [SELECT](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/SELECT.md), [UPDATE](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/UPDATE.md) and [DELETE](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/DELETE.md) statements.
##### Examples of limiting

```php
// ... LIMIT 10
$statement->limit(10);
```
14 changes: 14 additions & 0 deletions docs/Clause/OFFSET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### OFFSET clause

##### Methods

+ `offset()`

> Used only in [SELECT](https://github.com/FaaPz/Slim-PDO/blob/master/docs/Statement/SELECT.md) statements.
##### Examples of offsetting

```php
// ... OFFSET 20
$selectStatement->offset(20);
```
Loading

0 comments on commit 99e5032

Please sign in to comment.