Completed
Pull Request — master (#14)
by Tim
05:04
created

SqlStatementRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 76
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Media\Ee\Repositories\SqlStatements
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-product-media-ee
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Media\Ee\Repositories;
22
23
use TechDivision\Import\Product\Media\Ee\Utils\SqlStatementKeys;
24
25
/**
26
 * Repository class with the SQL statements to use.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2016 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import-product-media-ee
32
 * @link      http://www.techdivision.com
33
 */
34
class SqlStatementRepository extends \TechDivision\Import\Product\Media\Repositories\SqlStatementRepository
35
{
36
37
    /**
38
     * The SQL statements.
39
     *
40
     * @var array
41
     */
42
    private $statements = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
43
        SqlStatementKeys::PRODUCT_MEDIA_GALLERY_VALUE =>
44
            'SELECT *
45
               FROM catalog_product_entity_media_gallery_value
46
              WHERE value_id = :value_id
47
                AND store_id = :store_id
48
                AND row_id = :row_id',
49
        SqlStatementKeys::PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY =>
50
            'SELECT *
51
               FROM catalog_product_entity_media_gallery_value_to_entity
52
              WHERE value_id = :value_id
53
                AND row_id = :row_id',
54
        SqlStatementKeys::CREATE_PRODUCT_MEDIA_GALLERY_VALUE =>
55
            'INSERT
56
               INTO catalog_product_entity_media_gallery_value
57
                    (value_id,
58
                     store_id,
59
                     row_id,
60
                     label,
61
                     position,
62
                     disabled)
63
             VALUES (:value_id,
64
                     :store_id,
65
                     :row_id,
66
                     :label,
67
                     :position,
68
                     :disabled)',
69
        SqlStatementKeys::UPDATE_PRODUCT_MEDIA_GALLERY_VALUE =>
70
            'UPDATE catalog_product_entity_media_gallery_value
71
                SET value_id = :value_id,
72
                    store_id = :store_id,
73
                    row_id = :row_id,
74
                    label = :label,
75
                    position = :position,
76
                    disabled = :disabled
77
              WHERE record_id = :record_id',
78
        SqlStatementKeys::CREATE_PRODUCT_MEDIA_GALLERY_VALUE_TO_ENTITY =>
79
            'INSERT
80
               INTO catalog_product_entity_media_gallery_value_to_entity
81
                    (value_id,
82
                     row_id)
83
             VALUES (:value_id,
84
                     :row_id)',
85
        SqlStatementKeys::PRODUCT_MEDIA_GALLERIES_BY_SKU =>
86
            'SELECT t3.*
87
               FROM catalog_product_entity t1,
88
                    catalog_product_entity_media_gallery_value_to_entity t2,
89
                    catalog_product_entity_media_gallery t3
90
              WHERE t1.sku = :sku
91
                AND t2.row_id = t1.row_id
92
                AND t3.value_id = t2.value_id'
93
    );
94
95
    /**
96
     * Initialize the the SQL statements.
97
     */
98
    public function __construct()
99
    {
100
101
        // call the parent constructor
102
        parent::__construct();
103
104
        // merge the class statements
105
        foreach ($this->statements as $key => $statement) {
106
            $this->preparedStatements[$key] = $statement;
107
        }
108
    }
109
}
110