Completed
Pull Request — master (#10)
by
unknown
02:49
created
Classes/Service/Targets/InsertUpdateTable.php 1 patch
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
         $record_exists    = false;
107 107
         $entry_username   = $entry['0'];
108 108
 
109
-        $this->configuration    = $this->getConfiguration();
109
+        $this->configuration = $this->getConfiguration();
110 110
 
111 111
         if ($this->firstTime == "1") {
112 112
             $this->firstTime = 0;
113 113
             $this->getRecords("*");
114 114
         }
115 115
 
116
-        foreach ($this->table_records as $record){
117
-            if ($record['deleted'] == 0){
118
-                if ($record['username'] == $entry_username){
116
+        foreach ($this->table_records as $record) {
117
+            if ($record['deleted'] == 0) {
118
+                if ($record['username'] == $entry_username) {
119 119
                     $record_exists = true;
120 120
                     break;
121 121
                 }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
             }
126 126
         }
127 127
 
128
-        if ($record_exists){
128
+        if ($record_exists) {
129 129
             $this->updateRecord($entry);
130 130
             return TargetInterface::RESULT_UPDATE;
131 131
         }
@@ -144,12 +144,11 @@  discard block
 block discarded – undo
144 144
     public function getRecords($selectFields)
145 145
     {
146 146
         $fromTable        = $this->configuration['target_table'];
147
-        $whereStatement   = "pid = '".$this->configuration['pid']."'";
147
+        $whereStatement   = "pid = '" . $this->configuration['pid'] . "'";
148 148
 
149 149
         $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = 1;
150 150
 
151
-        $this->table_records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows
152
-        (
151
+        $this->table_records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
153 152
             $selectFields,
154 153
             $fromTable,
155 154
             $whereStatement
@@ -168,7 +167,7 @@  discard block
 block discarded – undo
168 167
         $field_values       = array();
169 168
         $into_table         = $this->configuration['target_table'];
170 169
 
171
-        foreach ($this->configuration["mapping"] as $key => $value){
170
+        foreach ($this->configuration["mapping"] as $key => $value) {
172 171
             $field_values[$value] = $entry[$key];
173 172
         }
174 173
 
@@ -176,7 +175,7 @@  discard block
 block discarded – undo
176 175
         $field_values['tstamp']   = time();
177 176
         $field_values['crdate']   = time();
178 177
               
179
-        $GLOBALS['TYPO3_DB']->exec_INSERTquery( $into_table, $field_values);
178
+        $GLOBALS['TYPO3_DB']->exec_INSERTquery($into_table, $field_values);
180 179
         $GLOBALS['TYPO3_DB']->sql_insert_id();
181 180
     }
182 181
 
@@ -190,19 +189,19 @@  discard block
 block discarded – undo
190 189
     public function updateRecord(array $entry)
191 190
     {
192 191
         $into_table       = $this->configuration['target_table'];
193
-        $whereStatement   = "pid = '".$this->configuration['pid']."' AND username = '".$entry[0]."'";
192
+        $whereStatement   = "pid = '" . $this->configuration['pid'] . "' AND username = '" . $entry[0] . "'";
194 193
                            
195 194
         $field_values     = array();
196 195
         $tmp_arr          = array();
197 196
 
198
-        foreach ($this->configuration["mapping"] as $key => $value){
197
+        foreach ($this->configuration["mapping"] as $key => $value) {
199 198
             $tmp_arr[$value] = $entry[$key];
200 199
         }
201 200
 
202
-        $field_values = $this->duplicateArray($tmp_arr,$this->configuration['exclude_from_update']);
201
+        $field_values = $this->duplicateArray($tmp_arr, $this->configuration['exclude_from_update']);
203 202
         $field_values['tstamp'] = time();
204 203
         
205
-        $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery( $into_table , $whereStatement , $field_values );
204
+        $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($into_table, $whereStatement, $field_values);
206 205
         $cnt = $GLOBALS['TYPO3_DB']->sql_affected_rows();
207 206
     }
208 207
 
@@ -221,7 +220,7 @@  discard block
 block discarded – undo
221 220
 
222 221
         if ($exclude_arr != null) {
223 222
             $exclude_max = count($exclude_arr);
224
-            if (count($exclude_arr) > 0){
223
+            if (count($exclude_arr) > 0) {
225 224
                 $exclude = true;
226 225
             }
227 226
 
@@ -231,7 +230,7 @@  discard block
 block discarded – undo
231 230
 
232 231
                 if ($exclude) {
233 232
                     foreach ($exclude_arr as $key => $value) {
234
-                        if ($value == $parentkey){
233
+                        if ($value == $parentkey) {
235 234
                             unset($arr[$parentkey]);
236 235
                         }
237 236
                     }
Please login to merge, or discard this patch.