|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2022 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Upscheme\Task; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class TablesMigratePropertyKey extends Base |
|
13
|
|
|
{ |
|
14
|
|
|
protected function tables() |
|
15
|
|
|
{ |
|
16
|
|
|
return [ |
|
17
|
|
|
'db-attribute' => 'mshop_attribute_property', |
|
18
|
|
|
'db-customer' => 'mshop_customer_property', |
|
19
|
|
|
'db-media' => 'mshop_media_property', |
|
20
|
|
|
'db-price' => 'mshop_price_property', |
|
21
|
|
|
'db-product' => 'mshop_product_property', |
|
22
|
|
|
]; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
public function after() : array |
|
27
|
|
|
{ |
|
28
|
|
|
return ['TypesMigrateColumns', 'TablesClearPropertyKey', 'Attribute', 'Customer', 'Media', 'Price', 'Product']; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
public function up() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->info( 'Update property "key" columns', 'v' ); |
|
35
|
|
|
|
|
36
|
|
|
foreach( $this->tables() as $rname => $table ) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->info( sprintf( 'Checking table %1$s', $table ), 'vv', 1 ); |
|
39
|
|
|
|
|
40
|
|
|
$db = $this->db( $rname ); |
|
41
|
|
|
$db2 = $this->db( $rname, true ); |
|
42
|
|
|
|
|
43
|
|
|
$update = $db->stmt()->update( $table )->set( $db->qi( 'key' ), '?' )->where( 'id', '?' ); |
|
44
|
|
|
|
|
45
|
|
|
$q = $db->stmt(); |
|
46
|
|
|
$result = $q->select( 'id', 'type', 'langid', 'value' )->from( $table ) |
|
47
|
|
|
->where( $db->qi( 'key' ) . ' = \'\'' )->execute(); |
|
48
|
|
|
|
|
49
|
|
|
while( $row = $result->fetch() ) |
|
50
|
|
|
{ |
|
51
|
|
|
$value = substr( $row['type'] . '|' . ( $row['langid'] ?: 'null' ) . '|' . $row['value'], 0, 255 ); |
|
52
|
|
|
$update->setParameters( $value, $row['id'] )->execute(); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$db2->close(); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|