Skip to content

Commit

Permalink
Merge pull request #28 from skipperbent/v3-development
Browse files Browse the repository at this point in the history
Version 3.4.2
  • Loading branch information
skipperbent authored Nov 28, 2017
2 parents bcd5275 + ba40d18 commit b9d54d5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ composer.lock
.DS_Store
.idea
test.php
*~
/devel/
*~
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0

before_script:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This library is stable, maintained and are used by many sites, including:
- [BookAndBegin.com](https://bookandbegin.com)

**Requirements:**
- PHP version 5.5 or higher is required.
- PHP 5.6 or higher is required.

#### Feedback and development

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
],
"require": {
"php": ">=5.5.0",
"php": ">=5.6",
"usmanhalalit/viocon": "1.0.1"
},
"require-dev": {
Expand Down
4 changes: 4 additions & 0 deletions src/Pecee/Pixie/ConnectionAdapters/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Mysql extends BaseAdapter
{
/**
* @param array $config
*
* @return mixed
* @throws Exception
*/
Expand All @@ -34,6 +35,9 @@ protected function doConnect(array $config)
$connectionString .= ";unix_socket={$config['unix_socket']}";
}

/**
* @var \PDO $connection
*/
$connection = $this->container->build(
\PDO::class,
[$connectionString, $config['username'], $config['password'], $config['options']]
Expand Down
4 changes: 4 additions & 0 deletions src/Pecee/Pixie/ConnectionAdapters/Pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Pgsql extends BaseAdapter
{
/**
* @param array $config
*
* @return mixed
* @throws Exception
*/
Expand All @@ -26,6 +27,9 @@ protected function doConnect(array $config)
$connectionString .= ";port={$config['port']}";
}

/**
* @var \PDO $connection
*/
$connection = $this->container->build(
\PDO::class,
[$connectionString, $config['username'], $config['password'], $config['options']]
Expand Down
3 changes: 2 additions & 1 deletion src/Pecee/Pixie/ConnectionAdapters/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Sqlite extends BaseAdapter
{
/**
* @param array $config
* @return mixed
*
* @return \PDO
* @throws Exception
*/
public function doConnect(array $config)
Expand Down
34 changes: 12 additions & 22 deletions src/Pecee/Pixie/QueryBuilder/QueryBuilderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,6 @@ public function prefix($table, $alias)
return $this->alias($table, $alias);
}

/**
* Parses correct data-type for PDO parameter.
*
* @param mixed $value
* @return int PDO-parameter type
*/
protected function parseDataType($value)
{
if (is_int($value) === true) {
return PDO::PARAM_INT;
}

if (is_bool($value) === true) {
return PDO::PARAM_BOOL;
}

return PDO::PARAM_STR;
}

/**
* Execute statement
*
Expand All @@ -215,17 +196,26 @@ public function statement($sql, array $bindings = [])

$pdoStatement = $this->pdo->prepare($sql);

/**
* NOTE:
* PHP 5.6 & 7 bug: https://bugs.php.net/bug.php?id=38546
* \PDO::PARAM_BOOL is not supported, use \PDO::PARAM_INT instead
*/

foreach ($bindings as $key => $value) {
$pdoStatement->bindValue(
is_int($key) ? $key + 1 : $key,
$value,
$this->parseDataType($value)
((is_int($value) === true || is_bool($value) === true) ? PDO::PARAM_INT : PDO::PARAM_STR)
);
}

$pdoStatement->execute();

return [$pdoStatement, microtime(true) - $start];
return [
$pdoStatement,
microtime(true) - $start,
];
}

/**
Expand Down Expand Up @@ -1066,7 +1056,7 @@ public function innerJoin($table, $key, $operator = null, $value = null)
*/
public function raw($value, $bindings = null)
{
if(is_array($bindings) === false) {
if (is_array($bindings) === false) {
$bindings = func_get_args();
array_shift($bindings);
}
Expand Down

0 comments on commit b9d54d5

Please sign in to comment.