diff --git a/CHANGELOG.md b/CHANGELOG.md index f84aad7..9541c72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Changelog +##### v1.7.2 ++ Updated `SelectStatement` class with: + - Minor fix `select()` method (working fix) + ##### v1.7.1 + Updated `SelectStatement` class with: - Minor fix `select()` method diff --git a/README.md b/README.md index c35d826..9cf7436 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,12 @@ $pwd = 'your_db_password'; $pdo = new \Slim\PDO\Database($dsn, $usr, $pwd); $qry = $pdo->prepare("SELECT * FROM users"); -$qry->execute(); + +$result = $qry->execute(); try { - var_dump($qry->fetchAll()); + var_dump($result->fetchAll()); } catch(\PDOException $e) { @@ -47,7 +48,7 @@ $selectStatement = $pdo->select() ->where('id', '=', 1234); $stmt = $selectStatement->execute(); -$data = $stmt->fetchAll(); +$data = $stmt->fetch(); // INSERT INTO users ( id , usr , pwd ) VALUES ( ? , ? , ? ) $insertStatement = $pdo->insert(array('id', 'usr', 'pwd')) diff --git a/composer.json b/composer.json index 0edb68d..c8abb95 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "slim/pdo", "description": "PDO database library for Slim Framework", - "version": "1.7.1", + "version": "1.7.2", "type": "library", "keywords": ["pdo", "database", "slim", "framework"], "homepage": "https://github.com/FaaPz/Slim-PDO", diff --git a/docs/Statement/SELECT.md b/docs/Statement/SELECT.md index d82b754..190d149 100644 --- a/docs/Statement/SELECT.md +++ b/docs/Statement/SELECT.md @@ -48,5 +48,5 @@ $selectStatement = $slimPdo->select() ->where('id', '=', 1234); $stmt = $selectStatement->execute(); -$data = $stmt->fetchAll(); +$data = $stmt->fetch(); ``` \ No newline at end of file diff --git a/src/PDO/Database.php b/src/PDO/Database.php index ce10033..b3a1d72 100644 --- a/src/PDO/Database.php +++ b/src/PDO/Database.php @@ -45,7 +45,7 @@ public function __construct( $dsn , $usr = null , $pwd = null , array $options = * @param array $columns * @return SelectStatement */ - public function select( array $columns ) + public function select( array $columns = array('*') ) { return new SelectStatement( $this , $columns ); } diff --git a/src/PDO/Statement/SelectStatement.php b/src/PDO/Statement/SelectStatement.php index 7d942e5..6c6bc97 100644 --- a/src/PDO/Statement/SelectStatement.php +++ b/src/PDO/Statement/SelectStatement.php @@ -50,16 +50,21 @@ class SelectStatement extends StatementContainer * @param Database $dbh * @param array $columns */ - public function __construct( Database $dbh , array $columns = array('*') ) + public function __construct( Database $dbh , array $columns ) { parent::__construct( $dbh ); + if( empty( $columns ) ) + { + $columns = array('*'); + } + $this->setColumns( $columns ); - $this->joinClause = new JoinClause(); - $this->groupClause = new GroupClause(); - $this->havingClause = new HavingClause(); - $this->offsetClause = new OffsetClause(); + $this->joinClause = new JoinClause(); + $this->groupClause = new GroupClause(); + $this->havingClause = new HavingClause(); + $this->offsetClause = new OffsetClause(); } /**