Skip to content

Commit

Permalink
Release version 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FaaPz committed Sep 14, 2015
1 parent 393b397 commit e2aa1dd
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
### Changelog

##### v1.8.0
+ [PSR-2 coding style guide](http://www.php-fig.org/psr/psr-2/) adopted
+ Updated `InsertStatement` class with:
- Added `columns()` method
+ Updated `UpdateStatement` class with:
- Added `set()` method
+ Updated `StatementContainer` class with:
- Added `$table` argument in `delete()` method
+ Updated `WhereClause` class with:
- Fixed `orWhereLike()`

##### v1.7.2
+ Updated `SelectStatement` class with:
- Minor fix `select()` method (working fix)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Use [Composer](https://getcomposer.org/)

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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "slim/pdo",
"description": "PDO database library for Slim Framework",
"version": "1.7.2",
"version": "1.8.0",
"type": "library",
"keywords": ["pdo", "database", "slim", "framework"],
"homepage": "https://github.com/FaaPz/Slim-PDO",
Expand Down
7 changes: 7 additions & 0 deletions docs/Statement/INSERT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
##### Methods

+ `into()`
+ `columns()`
+ `values()`

##### Examples
Expand All @@ -13,5 +14,11 @@ $insertStatement = $slimPdo->insert(array('id', 'usr', 'pwd'))
->into('users')
->values(array(1234, 'your_username', 'your_password'));

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

$insertId = $insertStatement->execute();
```
7 changes: 7 additions & 0 deletions docs/Statement/UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
##### Methods

+ `table()`
+ `set()`

##### Clauses

Expand All @@ -18,5 +19,11 @@ $updateStatement = $slimPdo->update(array('pwd' => 'your_new_password'))
->table('users')
->where('id', '=', 1234);

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

$affectedRows = $updateStatement->execute();
```
2 changes: 1 addition & 1 deletion src/PDO/Clause/WhereClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function whereLike($column, $rule = 'AND', $not = false)
*/
public function orWhereLike($column)
{
$this->whereLike($column);
$this->whereLike($column, 'OR');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/PDO/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function update(array $pairs)
/**
* @return DeleteStatement
*/
public function delete()
public function delete($table = null)
{
return new DeleteStatement($this);
return new DeleteStatement($this, $table);
}
}
5 changes: 4 additions & 1 deletion src/PDO/Statement/DeleteStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ class DeleteStatement extends StatementContainer
* Constructor.
*
* @param Database $dbh
* @param $table
*/
public function __construct(Database $dbh)
public function __construct(Database $dbh, $table)
{
parent::__construct($dbh);

$this->setTable($table);
}

/**
Expand Down
14 changes: 13 additions & 1 deletion src/PDO/Statement/InsertStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(Database $dbh, array $columns)
{
parent::__construct($dbh);

$this->setColumns($columns);
$this->columns($columns);
}

/**
Expand All @@ -40,6 +40,18 @@ public function into($table)
return $this;
}

/**
* @param array $columns
*
* @return $this
*/
public function columns(array $columns)
{
$this->setColumns($columns);

return $this;
}

/**
* @param array $values
*
Expand Down
20 changes: 16 additions & 4 deletions src/PDO/Statement/UpdateStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function __construct(Database $dbh, array $pairs)
{
parent::__construct($dbh);

foreach ($pairs as $column => $value) {
$this->columns[] = $column.' = ?';
$this->values[] = $value;
}
$this->set($pairs);
}

/**
Expand All @@ -43,6 +40,21 @@ public function table($table)
return $this;
}

/**
* @param array $pairs
*
* @return $this
*/
public function set(array $pairs)
{
foreach ($pairs as $column => $value) {
$this->columns[] = $column.' = ?';
$this->values[] = $value;
}

return $this;
}

/**
* @return string
*/
Expand Down

0 comments on commit e2aa1dd

Please sign in to comment.