1 | <?php |
||
19 | class Connection extends CoreConnection |
||
20 | { |
||
21 | /** |
||
22 | * @var Typo3Service |
||
23 | */ |
||
24 | private $typo3Service; |
||
25 | |||
26 | /** |
||
27 | * Inserts a table row with specified data. |
||
28 | * |
||
29 | * All SQL identifiers are expected to be unquoted and will be quoted when building the query. |
||
30 | * Table expression and columns are not escaped and are not safe for user-input. |
||
31 | * |
||
32 | * @param string $tableName The name of the table to insert data into. |
||
33 | * @param array $data An associative array containing column-value pairs. |
||
34 | * @param array $types Types of the inserted data. |
||
35 | * |
||
36 | * @return int The number of affected rows. |
||
37 | */ |
||
38 | public function insert($tableName, array $data, array $types = []): int |
||
39 | { |
||
40 | return parent::insert( |
||
41 | $tableName, |
||
42 | $this->getTypo3Service()->modifyInsertFields($tableName, $data), |
||
43 | $types |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Bulk inserts table rows with specified data. |
||
49 | * |
||
50 | * All SQL identifiers are expected to be unquoted and will be quoted when building the query. |
||
51 | * Table expression and columns are not escaped and are not safe for user-input. |
||
52 | * |
||
53 | * @param string $tableName The name of the table to insert data into. |
||
54 | * @param array $data An array containing associative arrays of column-value pairs. |
||
55 | * @param array $columns An array containing associative arrays of column-value pairs. |
||
56 | * @param array $types Types of the inserted data. |
||
57 | * |
||
58 | * @return int The number of affected rows. |
||
59 | */ |
||
60 | public function bulkInsert(string $tableName, array $data, array $columns = [], array $types = []): int |
||
69 | |||
70 | /** |
||
71 | * Executes an SQL UPDATE statement on a table. |
||
72 | * |
||
73 | * All SQL identifiers are expected to be unquoted and will be quoted when building the query. |
||
74 | * Table expression and columns are not escaped and are not safe for user-input. |
||
75 | * |
||
76 | * @param string $tableName The name of the table to update. |
||
77 | * @param array $data An associative array containing column-value pairs. |
||
78 | * @param array $identifier The update criteria. An associative array containing column-value pairs. |
||
79 | * @param array $types Types of the merged $data and $identifier arrays in that order. |
||
80 | * |
||
81 | * @return int The number of affected rows. |
||
82 | */ |
||
83 | public function update($tableName, array $data, array $identifier, array $types = []): int |
||
84 | { |
||
85 | if (isset($data['uid']) && $this->getTypo3Service()->needsSequenzer($tableName)) { |
||
86 | throw new \InvalidArgumentException('no uid allowed in update statement!', 1564122222); |
||
87 | } |
||
88 | |||
89 | return parent::update( |
||
90 | $tableName, |
||
91 | $data, |
||
92 | $identifier, |
||
93 | $types |
||
94 | ); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * create instance of Typo3Service by lazy-loading |
||
99 | * |
||
100 | * Why we do this? |
||
101 | * Because some unittests backup the variable $GLOBALS (and so, also the variable $GLOBALS['TYPO3_DB']), which means, that this |
||
102 | * object/class will be serialized/unserialized, so the instance of Typo3Service will be null after unserialization! |
||
103 | * |
||
104 | * @return Typo3Service |
||
105 | */ |
||
106 | 1 | protected function getTypo3Service() |
|
114 | } |
||
115 |