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/OrderByStatement.php +22 -1 2.30.04.16.9 View file →
@@ -3,8 +3,9 @@
3 3 namespace Give\Framework\QueryBuilder\Concerns;
4 4
5 5 use Give\Framework\Database\DB;
6 6 use Give\Framework\QueryBuilder\Clauses\OrderBy;
7 +use Give\Framework\QueryBuilder\Clauses\RawSQL;
7 8
8 9 /**
9 10 * @since 2.19.0
10 11 */
@@ -28,8 +29,25 @@
28 29 return $this;
29 30 }
30 31
31 32 /**
33 + * Add raw SQL Order By statement
34 + *
35 + * @since 4.0.0
36 + *
37 + * @param $sql
38 + * @param ...$args
39 + *
40 + * @return $this
41 + */
42 + public function orderByRaw($sql, ...$args)
43 + {
44 + $this->orderBys[] = new RawSQL($sql, $args);
45 +
46 + return $this;
47 + }
48 +
49 + /**
32 50 * @return array|string[]
33 51 */
34 52 protected function getOrderBySQL()
35 53 {
@@ -38,9 +56,12 @@
38 56 }
39 57
40 58 $orderBys = implode(
41 59 ', ',
42 - array_map(function (OrderBy $order) {
60 + array_map(function ($order) {
61 + if ($order instanceof RawSQL) {
62 + return DB::prepare('%1s', $order->sql);
63 + }
43 64 return DB::prepare('%1s %2s', $order->column, $order->direction);
44 65 }, $this->orderBys)
45 66 );
46 67