From 19c2d1235b6074b8bca4311818dafd127e9a01ef Mon Sep 17 00:00:00 2001 From: ComStudio Date: Wed, 23 Sep 2015 16:41:03 +0200 Subject: [PATCH 01/10] Update Query.php --- src/Query/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Query/Query.php b/src/Query/Query.php index 498805b..5fbd94d 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -126,7 +126,7 @@ public function orderBy($orders) if (is_numeric($key)) { $queryOrders[] = $value; } else { - $queryOrders[] = $key.' '.$value; + $queryOrders[] = $key.' '.'$value'; } } From e04c55ccdda95e4524db62f5a2f2772499c819e6 Mon Sep 17 00:00:00 2001 From: ComStudio Date: Wed, 23 Sep 2015 16:42:31 +0200 Subject: [PATCH 02/10] Update Query.php --- src/Query/Query.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Query/Query.php b/src/Query/Query.php index 5fbd94d..557e77a 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -126,7 +126,7 @@ public function orderBy($orders) if (is_numeric($key)) { $queryOrders[] = $value; } else { - $queryOrders[] = $key.' '.'$value'; + $queryOrders[] = $key.' '.$value; } } @@ -141,7 +141,7 @@ public function where($conditions, $or = false) if (is_numeric($key)) { $fieldConditions[] = $value; } else { - $fieldConditions[] = $key.' = '.$value; + $fieldConditions[] = $key.' = "'.$value.'"'; } } From d5da00f8f6d16ecd2ef38d7d8c00a6865698700b Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Tue, 29 Sep 2015 19:41:41 +0200 Subject: [PATCH 03/10] Update Query.php --- src/Query/Query.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Query/Query.php b/src/Query/Query.php index 557e77a..56e21c1 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -198,4 +198,9 @@ public function close() { return $this->pdo->disconnect(); } + + public function error() + { + return $this->pdo->sqlResult; + } } From cc23c36c47304852335c44ca01ded18a14e146cd Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Tue, 29 Sep 2015 20:01:02 +0200 Subject: [PATCH 04/10] Update Query.php --- src/Query/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Query/Query.php b/src/Query/Query.php index 56e21c1..e9be021 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -201,6 +201,6 @@ public function close() public function error() { - return $this->pdo->sqlResult; + return $this->pdo->get(); } } From 43b01a0f13227758183b1df53d7feadd214ec02e Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Tue, 6 Oct 2015 00:36:39 +0200 Subject: [PATCH 05/10] Update Query.php --- src/Query/Query.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Query/Query.php b/src/Query/Query.php index e9be021..80282b4 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -134,6 +134,17 @@ public function orderBy($orders) return $this; } + + public function groupBy($groups) + { + foreach ($groups as $value) { + $queryGroups[] = $value; + } + + $this->sqlQuery .=' GROUP BY '.implode(',', $queryGroups); + + return $this; + } public function where($conditions, $or = false) { From 93678a0330dd6204ea611b6ba793ed5489a6af42 Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Sat, 17 Oct 2015 21:28:53 +0200 Subject: [PATCH 06/10] Update Query.php --- src/Query/Query.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Query/Query.php b/src/Query/Query.php index 80282b4..c6dce2c 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -134,7 +134,7 @@ public function orderBy($orders) return $this; } - + public function groupBy($groups) { foreach ($groups as $value) { @@ -152,11 +152,11 @@ public function where($conditions, $or = false) if (is_numeric($key)) { $fieldConditions[] = $value; } else { - $fieldConditions[] = $key.' = "'.$value.'"'; + $fieldConditions[] = $key.' = '.$value; } } - if (isset($or)) { + if (isset($or) && $or !== false) { $this->sqlQuery .= ' WHERE '.implode(' OR ', $fieldConditions); return $this; @@ -209,7 +209,7 @@ public function close() { return $this->pdo->disconnect(); } - + public function error() { return $this->pdo->get(); From 6e8462c81d65ea16d8fe4696af696e404ca94037 Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Wed, 4 Nov 2015 23:45:57 +0100 Subject: [PATCH 07/10] fix delete return --- src/Query/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Query/Query.php b/src/Query/Query.php index c6dce2c..77c66cd 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -103,7 +103,7 @@ public function get(array $fetchAttributes = null, array $executeAttributes = nu public function exec() { try { - return $this->query($this->sqlQuery, $this->sqlAttributes, false); + return $this->query($this->sqlQuery, ['all'], false); } catch (Exception $e) { return [$e->getMessage()]; } From 6750902b560af5912ff3bd2fb391fbfc01189559 Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Wed, 4 Nov 2015 23:53:04 +0100 Subject: [PATCH 08/10] fix update exec --- src/Query/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Query/Query.php b/src/Query/Query.php index 77c66cd..8c390eb 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -103,7 +103,7 @@ public function get(array $fetchAttributes = null, array $executeAttributes = nu public function exec() { try { - return $this->query($this->sqlQuery, ['all'], false); + return $this->query($this->sqlQuery, empty($this->sqlAttributes) ? ['all'] : $this->sqlAttributes, false); } catch (Exception $e) { return [$e->getMessage()]; } From 5ed4ea7a5abbdc5722b16aa8cb74d13603e38a56 Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Sun, 6 Dec 2015 01:15:53 +0100 Subject: [PATCH 09/10] fix issue when result is boolean --- src/Database/Mysql/Mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Mysql/Mysql.php b/src/Database/Mysql/Mysql.php index d80250d..c88fd79 100644 --- a/src/Database/Mysql/Mysql.php +++ b/src/Database/Mysql/Mysql.php @@ -61,7 +61,7 @@ public function query($statement, $fetchAll = true, $fetchMode = 'obj') $this->sqlQuery = $this->pdo ->query($statement); - if (isset($this->sqlQuery)) { + if (isset($this->sqlQuery) && !is_bool($this->sqlQuery)) { $this->rowCount = $this->sqlQuery ->rowCount(); From 87bccbf4c0b05d2e68bf629499d8913bae226455 Mon Sep 17 00:00:00 2001 From: Andrzej Kostrzewa Date: Sun, 6 Dec 2015 01:16:47 +0100 Subject: [PATCH 10/10] fix issue when result is boolean --- src/Database/Mysql/Mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Mysql/Mysql.php b/src/Database/Mysql/Mysql.php index c88fd79..421c274 100644 --- a/src/Database/Mysql/Mysql.php +++ b/src/Database/Mysql/Mysql.php @@ -97,7 +97,7 @@ public function prepare($statement, array $attributes, $fetchAll = true, $fetchM $executeResponse = $this->sqlQuery ->execute($attributes); - if (isset($this->sqlQuery)) { + if (isset($this->sqlQuery) && !is_bool($this->sqlQuery)) { $this->rowCount = $this->sqlQuery ->rowCount();