1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Magic360\Repositories\SqlStatementRepository |
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 2018 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\Repositories; |
23
|
|
|
|
24
|
|
|
use TechDivision\Import\Product\Magic360\Utils\SqlStatementKeys; |
25
|
|
|
use TechDivision\Import\Repositories\AbstractSqlStatementRepository; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Repository class with the SQL statements to use. |
29
|
|
|
* |
30
|
|
|
* @author Tim Wagner <[email protected]> |
31
|
|
|
* @author Bernhard Wick <[email protected]> |
32
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
33
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
34
|
|
|
* @link https://github.com/techdivision/import-product-magic360 |
35
|
|
|
* @link http://www.techdivision.com |
36
|
|
|
*/ |
37
|
|
|
class SqlStatementRepository extends AbstractSqlStatementRepository |
38
|
|
|
{ |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The SQL statements. |
42
|
|
|
* |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
private $statements = array( |
46
|
|
|
SqlStatementKeys::MAGIC360_GALLERY => |
47
|
|
|
'SELECT * |
48
|
|
|
FROM magic360_gallery |
49
|
|
|
WHERE product_id = :product_id |
50
|
|
|
AND position = :position', |
51
|
|
|
SqlStatementKeys::MAGIC360_COLUMNS => |
52
|
|
|
'SELECT * |
53
|
|
|
FROM magic360_columns |
54
|
|
|
WHERE product_id = :product_id', |
55
|
|
|
SqlStatementKeys::CREATE_MAGIC360_GALLERY => |
56
|
|
|
'INSERT |
57
|
|
|
INTO magic360_gallery |
58
|
|
|
(product_id, |
59
|
|
|
position, |
60
|
|
|
file) |
61
|
|
|
VALUES (:product_id, |
62
|
|
|
:position, |
63
|
|
|
:file)', |
64
|
|
|
SqlStatementKeys::UPDATE_MAGIC360_GALLERY => |
65
|
|
|
'UPDATE magic360_gallery |
66
|
|
|
SET product_id = :product_id, |
67
|
|
|
position = :position, |
68
|
|
|
file = :file |
69
|
|
|
WHERE id = :id', |
70
|
|
|
SqlStatementKeys::DELETE_MAGIC360_GALLERY => |
71
|
|
|
'DELETE FROM magic360_gallery WHERE product_id = :product_id', |
72
|
|
|
SqlStatementKeys::CREATE_MAGIC360_COLUMNS => |
73
|
|
|
'INSERT |
74
|
|
|
INTO magic360_columns |
75
|
|
|
(product_id, |
76
|
|
|
columns) |
77
|
|
|
VALUES (:product_id, |
78
|
|
|
:columns)', |
79
|
|
|
SqlStatementKeys::UPDATE_MAGIC360_COLUMNS => |
80
|
|
|
'UPDATE magic360_columns |
81
|
|
|
SET product_id = :product_id, |
82
|
|
|
columns = :columns |
83
|
|
|
WHERE product_id = :product_id', |
84
|
|
|
SqlStatementKeys::DELETE_MAGIC360_COLUMNS => |
85
|
|
|
'DELETE FROM magic360_columns WHERE product_id = :product_id', |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Initialize the the SQL statements. |
90
|
|
|
*/ |
91
|
|
|
public function __construct() |
92
|
|
|
{ |
93
|
|
|
|
94
|
|
|
// merge the class statements |
95
|
|
|
foreach ($this->statements as $key => $statement) { |
96
|
|
|
$this->preparedStatements[$key] = $statement; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|