These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * set the order id number. |
||
5 | * |
||
6 | * @authors: Nicolaas [at] Sunny Side Up .co.nz |
||
7 | * @package: ecommerce |
||
8 | * @sub-package: tasks |
||
9 | * @inspiration: Silverstripe Ltd, Jeremy |
||
10 | **/ |
||
11 | class EcommerceTaskSetOrderIDStartingNumber extends BuildTask |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | protected $title = 'Set Order ID starting number'; |
||
14 | |||
15 | protected $description = 'Sets the starting order number with all order numbers following this number.'; |
||
16 | |||
17 | public function run($request) |
||
18 | { |
||
19 | |||
20 | //set starting order number ID |
||
21 | $number = EcommerceConfig::get('Order', 'order_id_start_number'); |
||
22 | $currentMax = 0; |
||
23 | //set order ID |
||
24 | if ($number) { |
||
25 | $count = DB::query('SELECT COUNT( "ID" ) FROM "Order" ')->value(); |
||
26 | if ($count > 0) { |
||
27 | $currentMax = DB::Query('SELECT MAX( "ID" ) FROM "Order"')->value(); |
||
28 | } |
||
29 | if ($number > $currentMax) { |
||
30 | DB::query("ALTER TABLE \"Order\" AUTO_INCREMENT = $number ROW_FORMAT = DYNAMIC "); |
||
31 | DB::alteration_message('Change OrderID start number to '.$number, 'created'); |
||
32 | } else { |
||
33 | DB::alteration_message('Can not set OrderID start number to '.$number.' because this number has already been used.', 'deleted'); |
||
34 | } |
||
35 | } else { |
||
36 | DB::alteration_message('Starting OrderID has not been set.', 'deleted'); |
||
37 | } |
||
38 | } |
||
39 | } |
||
40 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.