PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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
give / src / Campaigns / Migrations / RevenueTable / AssociateDonationsToCampaign.php

AssociateDonationsToCampaign.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Campaigns/Migrations/RevenueTable/AssociateDonationsToCampaign.php

55 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Campaigns\Migrations\RevenueTable;
4
5 use Give\Framework\Database\DB;
6 use Give\Framework\Database\Exceptions\DatabaseQueryException;
7 use Give\Framework\Migrations\Contracts\Migration;
8 use Give\Framework\Migrations\Exceptions\DatabaseMigrationException;
9
10 /**
11 * @since 4.0.0
12 */
13 class AssociateDonationsToCampaign extends Migration
14 {
15 /**
16 * @inheritDoc
17 */
18 public static function id(): string
19 {
20 return 'associate_donations_to_campaign';
21 }
22
23 /**
24 * @inheritDoc
25 */
26 public static function title(): string
27 {
28 return 'Associate donations to campaign';
29 }
30
31 /**
32 * @inheritdoc
33 */
34 public static function timestamp(): string
35 {
36 return strtotime('2024-10-14 00:00:01');
37 }
38
39 /**
40 * @inheritDoc
41 * @throws DatabaseMigrationException
42 */
43 public function run()
44 {
45 global $wpdb;
46
47 try {
48 DB::query("UPDATE {$wpdb->give_revenue} AS revenue JOIN {$wpdb->give_campaign_forms} forms ON revenue.form_id = forms.form_id SET revenue.campaign_id = forms.campaign_id");
49 } catch (DatabaseQueryException $exception) {
50 throw new DatabaseMigrationException("An error occurred while updating the {$wpdb->give_revenue} table", 0,
51 $exception);
52 }
53 }
54 }
55