PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | src/Framework/QueryBuilder/Concerns/Aggregate.php +4 -3 2.30.04.16.9 View file →
@@ -11,8 +11,9 @@
11 11 {
12 12 /**
13 13 * Returns the number of rows returned by a query
14 14 *
15 + * @since 4.10.0 Return 0 when no result is null
15 16 * @since 2.19.0
16 17 * @param null|string $column
17 18 *
18 19 * @return int
@@ -18,9 +19,9 @@
18 19 * @return int
19 20 */
20 21 public function count($column = null)
21 22 {
22 - $column = ( ! $column || $column === '*') ? '1' : trim($column);
23 + $column = (!$column || $column === '*') ? '1' : trim($column);
23 24
24 25 if (empty($this->selects)) {
25 26 $this->selects[] = new RawSQL('SELECT COUNT(%1s) AS count', $column);
26 27 } else {
@@ -26,9 +27,10 @@
26 27 } else {
27 28 $this->selects[] = new RawSQL('COUNT(%1s) AS count', $column);
28 29 }
29 30
30 - return +$this->get()->count;
31 + $result = $this->get();
32 + return is_null($result) ? 0 : +$result->count;
31 33 }
32 34
33 35 /**
34 36 * Returns the total sum in a set of values
@@ -43,9 +45,8 @@
43 45 $this->selects[] = new RawSQL('SELECT SUM(%1s) AS sum', $column);
44 46
45 47 return +$this->get()->sum;
46 48 }
47 -
48 49
49 50 /**
50 51 * Get the average value in a set of values
51 52 *