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 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||
5 | * @copyright Aimeos (aimeos.org), 2017 |
||
6 | */ |
||
7 | |||
8 | |||
9 | namespace Aimeos\MW\Setup\Task; |
||
10 | |||
11 | |||
12 | /** |
||
13 | * Adds the weekday values in order tables |
||
14 | */ |
||
15 | class OrderAddWeekday extends \Aimeos\MW\Setup\Task\Base |
||
16 | { |
||
17 | /** |
||
18 | * Returns the list of task names which this task depends on. |
||
19 | * |
||
20 | * @return string[] List of task names |
||
21 | */ |
||
22 | public function getPreDependencies() |
||
23 | { |
||
24 | return array( 'TablesCreateMShop' ); |
||
25 | } |
||
26 | |||
27 | |||
28 | /** |
||
29 | * Returns the list of task names which depends on this task. |
||
30 | * |
||
31 | * @return string[] List of task names |
||
32 | */ |
||
33 | public function getPostDependencies() |
||
34 | { |
||
35 | return []; |
||
36 | } |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Migrate database schema |
||
41 | */ |
||
42 | public function migrate() |
||
43 | { |
||
44 | $dbdomain = 'db-order'; |
||
45 | $this->msg( 'Populate weekday column in order table', 0 ); |
||
46 | |||
47 | if( $this->getSchema( $dbdomain )->tableExists( 'mshop_order' ) === false ) |
||
48 | { |
||
49 | $this->status( 'OK' ); |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | $start = 0; |
||
54 | $conn = $this->getConnection( $dbdomain ); |
||
55 | $select = 'SELECT "id", "ctime" FROM "mshop_order" WHERE "cwday" = \'\' LIMIT 1000 OFFSET :offset'; |
||
56 | $update = 'UPDATE "mshop_order" SET "cwday" = ? WHERE "id" = ?'; |
||
57 | |||
58 | $stmt = $conn->create( $update, \Aimeos\MW\DB\Connection\Base::TYPE_PREP ); |
||
59 | |||
60 | do |
||
61 | { |
||
62 | $count = 0; |
||
63 | $map = []; |
||
64 | $sql = str_replace( ':offset', $start, $select ); |
||
65 | $result = $conn->create( $sql )->execute(); |
||
66 | |||
67 | while( ( $row = $result->fetch() ) !== false ) |
||
68 | { |
||
69 | $map[$row['id']] = $row['ctime']; |
||
70 | $count++; |
||
71 | } |
||
72 | |||
73 | foreach( $map as $id => $ctime ) |
||
74 | { |
||
75 | list( $date, $time ) = explode( ' ', $ctime ); |
||
0 ignored issues
–
show
|
|||
76 | |||
77 | $stmt->bind( 1, date_create_from_format( 'Y-m-d', $date )->format( 'w' ) ); |
||
78 | $stmt->bind( 2, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT ); |
||
79 | |||
80 | $stmt->execute()->finish(); |
||
81 | } |
||
82 | |||
83 | $start += $count; |
||
84 | } |
||
85 | while( $count === 1000 ); |
||
86 | |||
87 | $this->status( 'done' ); |
||
88 | } |
||
89 | } |
||
90 |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.