Completed
Push — master ( c48b0d...f6470c )
by Tim
13s
created

SqlStatements::__clone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Magic360\Utils\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
 * @author    Bernhard Wick <[email protected]>
16
 * @copyright 2017 TechDivision GmbH <[email protected]>
17
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
 * @link      https://github.com/techdivision/import-product-magic360
19
 * @link      http://www.techdivision.com
20
 */
21
22
namespace TechDivision\Import\Product\Magic360\Utils;
23
24
use TechDivision\Import\Utils\AbstractSqlStatements;
25
26
/**
27
 * Collection of SQL statements used for data manipulation.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @author    Bernhard Wick <[email protected]>
31
 * @copyright 2017 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/techdivision/import-product-magic360
34
 * @link      http://www.techdivision.com
35
 */
36
class SqlStatements extends AbstractSqlStatements
37
{
38
39
    /**
40
     * The SQL statement to load an existing magic360 gallery byproduct ID and position.
41
     *
42
     * @var string MAGIC360_GALLERY
43
     */
44
    const MAGIC360_GALLERY = 'magic360_gallery';
45
46
    /**
47
     * The SQL statement to load an existing magic360 column by product ID.
48
     *
49
     * @var string MAGIC360_COLUMNS
50
     */
51
    const MAGIC360_COLUMNS = 'magic360_colums';
52
53
    /**
54
     * The SQL statement to create a new magic360 gallery entry.
55
     *
56
     * @var string CREATE_MAGIC360_GALLERY
57
     */
58
    const CREATE_MAGIC360_GALLERY = 'create.magic360_gallery';
59
60
    /**
61
     * The SQL statement to update an existing magic360 gallery entry.
62
     *
63
     * @var string UPDATE_MAGIC360_GALLERY
64
     */
65
    const UPDATE_MAGIC360_GALLERY = 'update.magic360_gallery';
66
67
    /**
68
     * The SQL statement to delete an existing magic360 gallery entry.
69
     *
70
     * @var string DELETE_MAGIC360_GALLERY
71
     */
72
    const DELETE_MAGIC360_GALLERY = 'delete.magic360_gallery';
73
74
    /**
75
     * The SQL statement to create a new magic360 column entry.
76
     *
77
     * @var string CREATE_MAGIC360_COLUMNS
78
     */
79
    const CREATE_MAGIC360_COLUMNS = 'create.magic360_columns';
80
81
    /**
82
     * The SQL statement to update an existing magic360 column entry.
83
     *
84
     * @var string UPDATE_MAGIC360_COLUMNS
85
     */
86
    const UPDATE_MAGIC360_COLUMNS = 'update.magic360_columns';
87
88
    /**
89
     * The SQL statement to update an existing magic360 column entry.
90
     *
91
     * @var string DELETE_MAGIC360_COLUMNS
92
     */
93
    const DELETE_MAGIC360_COLUMNS = 'delete.magic360_columns';
94
95
    /**
96
     * The SQL statements.
97
     *
98
     * @var array
99
     */
100
    private $statements = array(
101
        SqlStatements::MAGIC360_GALLERY =>
102
            'SELECT *
103
               FROM magic360_gallery
104
              WHERE product_id = :product_id
105
                AND position = :position',
106
        SqlStatements::MAGIC360_COLUMNS =>
107
            'SELECT *
108
               FROM magic360_columns
109
              WHERE product_id = :product_id',
110
        SqlStatements::CREATE_MAGIC360_GALLERY =>
111
            'INSERT
112
               INTO magic360_gallery
113
                    (product_id,
114
                     position,
115
                     file)
116
             VALUES (:product_id,
117
                     :position,
118
                     :file)',
119
        SqlStatements::UPDATE_MAGIC360_GALLERY =>
120
            'UPDATE magic360_gallery
121
                SET product_id = :product_id,
122
                    position = :position,
123
                    file = :file
124
              WHERE id = :id',
125
        SqlStatements::DELETE_MAGIC360_GALLERY =>
126
            'DELETE FROM magic360_gallery WHERE product_id = :product_id',
127
        SqlStatements::CREATE_MAGIC360_COLUMNS =>
128
            'INSERT
129
               INTO magic360_columns
130
                    (product_id,
131
                     columns)
132
             VALUES (:product_id,
133
                     :columns)',
134
        SqlStatements::UPDATE_MAGIC360_COLUMNS =>
135
            'UPDATE magic360_columns
136
                SET product_id = :product_id,
137
                    columns = :columns
138
              WHERE product_id = :product_id',
139
        SqlStatements::DELETE_MAGIC360_COLUMNS =>
140
            'DELETE FROM magic360_columns WHERE product_id = :product_id',
141
    );
142
143
    /**
144
     * Initialize the the SQL statements.
145
     */
146
    public function __construct()
147
    {
148
149
        // merge the class statements
150
        foreach ($this->statements as $key => $statement) {
151
            $this->preparedStatements[$key] = $statement;
152
        }
153
    }
154
}
155