| @@ 199-237 (lines=39) @@ | ||
| 196 | } |
|
| 197 | } |
|
| 198 | ||
| 199 | foreach ($data as $table => $rows) { |
|
| 200 | // Check that at least one row exists |
|
| 201 | if (!isset($rows[0])) { |
|
| 202 | continue; |
|
| 203 | } |
|
| 204 | ||
| 205 | $q = $handler->createInsertQuery(); |
|
| 206 | $q->insertInto($handler->quoteIdentifier($table)); |
|
| 207 | ||
| 208 | // Contains the bound parameters |
|
| 209 | $values = array(); |
|
| 210 | ||
| 211 | // Binding the parameters |
|
| 212 | foreach ($rows[0] as $col => $val) { |
|
| 213 | $q->set( |
|
| 214 | $handler->quoteIdentifier($col), |
|
| 215 | $q->bindParam($values[$col]) |
|
| 216 | ); |
|
| 217 | } |
|
| 218 | ||
| 219 | $stmt = $q->prepare(); |
|
| 220 | ||
| 221 | foreach ($rows as $row) { |
|
| 222 | try { |
|
| 223 | // This CANNOT be replaced by: |
|
| 224 | // $values = $row |
|
| 225 | // each $values[$col] is a PHP reference which should be |
|
| 226 | // kept for parameters binding to work |
|
| 227 | foreach ($row as $col => $val) { |
|
| 228 | $values[$col] = $val; |
|
| 229 | } |
|
| 230 | ||
| 231 | $stmt->execute(); |
|
| 232 | } catch (Exception $e) { |
|
| 233 | echo "$table ( ", implode(', ', $row), " )\n"; |
|
| 234 | throw $e; |
|
| 235 | } |
|
| 236 | } |
|
| 237 | } |
|
| 238 | ||
| 239 | $this->applyStatements($this->getPostInsertStatements()); |
|
| 240 | } |
|
| @@ 175-213 (lines=39) @@ | ||
| 172 | $data = require $file; |
|
| 173 | $db = $this->getDatabaseHandler(); |
|
| 174 | ||
| 175 | foreach ($data as $table => $rows) { |
|
| 176 | // Check that at least one row exists |
|
| 177 | if (!isset($rows[0])) { |
|
| 178 | continue; |
|
| 179 | } |
|
| 180 | ||
| 181 | $q = $db->createInsertQuery(); |
|
| 182 | $q->insertInto($db->quoteIdentifier($table)); |
|
| 183 | ||
| 184 | // Contains the bound parameters |
|
| 185 | $values = array(); |
|
| 186 | ||
| 187 | // Binding the parameters |
|
| 188 | foreach ($rows[0] as $col => $val) { |
|
| 189 | $q->set( |
|
| 190 | $db->quoteIdentifier($col), |
|
| 191 | $q->bindParam($values[$col]) |
|
| 192 | ); |
|
| 193 | } |
|
| 194 | ||
| 195 | $stmt = $q->prepare(); |
|
| 196 | ||
| 197 | foreach ($rows as $row) { |
|
| 198 | try { |
|
| 199 | // This CANNOT be replaced by: |
|
| 200 | // $values = $row |
|
| 201 | // each $values[$col] is a PHP reference which should be |
|
| 202 | // kept for parameters binding to work |
|
| 203 | foreach ($row as $col => $val) { |
|
| 204 | $values[$col] = $val; |
|
| 205 | } |
|
| 206 | ||
| 207 | $stmt->execute(); |
|
| 208 | } catch (Exception $e) { |
|
| 209 | echo "$table ( ", implode(', ', $row), " )\n"; |
|
| 210 | throw $e; |
|
| 211 | } |
|
| 212 | } |
|
| 213 | } |
|
| 214 | ||
| 215 | $this->resetSequences(); |
|
| 216 | } |
|