@@ -14,22 +14,22 @@ discard block |
||
| 14 | 14 | $statement = $pdo->prepare($query); |
| 15 | 15 | $statement->execute(); |
| 16 | 16 | while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { |
| 17 | - $query = " |
|
| 17 | + $query = " |
|
| 18 | 18 | SELECT `activity`.`id` |
| 19 | 19 | FROM `jpemeric_stream`.`activity` |
| 20 | 20 | INNER JOIN `jpemeric_stream`.`blog2` ON `blog2`.`id` = `activity`.`type_id` AND |
| 21 | 21 | `blog2`.`permalink` LIKE '{$row['url']}%' |
| 22 | 22 | WHERE `type` = 'blog'"; |
| 23 | - $updateRecords = $pdo->fetchAll($query); |
|
| 24 | - if (count($updateRecords) !== 1) { |
|
| 25 | - if ($row['url'] == 'http://blog.jacobemerick.com/hiking/slightly-shuffled/') { |
|
| 26 | - continue; |
|
| 27 | - } |
|
| 28 | - var_dump($updateRecords); |
|
| 29 | - var_dump($row); |
|
| 30 | - exit('problem with blog uniqueness'); |
|
| 31 | - } |
|
| 32 | - $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 23 | + $updateRecords = $pdo->fetchAll($query); |
|
| 24 | + if (count($updateRecords) !== 1) { |
|
| 25 | + if ($row['url'] == 'http://blog.jacobemerick.com/hiking/slightly-shuffled/') { |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 28 | + var_dump($updateRecords); |
|
| 29 | + var_dump($row); |
|
| 30 | + exit('problem with blog uniqueness'); |
|
| 31 | + } |
|
| 32 | + $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $query = " |
@@ -40,17 +40,17 @@ discard block |
||
| 40 | 40 | $statement = $pdo->prepare($query); |
| 41 | 41 | $statement->execute(); |
| 42 | 42 | while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { |
| 43 | - $query = " |
|
| 43 | + $query = " |
|
| 44 | 44 | SELECT `activity`.`id` |
| 45 | 45 | FROM `jpemeric_stream`.`activity` |
| 46 | 46 | INNER JOIN `jpemeric_stream`.`goodread` ON `goodread`.`id` = `activity`.`type_id` AND |
| 47 | 47 | `goodread`.`permalink` = :url |
| 48 | 48 | WHERE `type` = 'book'"; |
| 49 | - $updateRecords = $pdo->fetchAll($query, ['url' => $row['link']]); |
|
| 50 | - if (count($updateRecords) !== 1) { |
|
| 51 | - exit('problem with book uniqueness'); |
|
| 52 | - } |
|
| 53 | - $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 49 | + $updateRecords = $pdo->fetchAll($query, ['url' => $row['link']]); |
|
| 50 | + if (count($updateRecords) !== 1) { |
|
| 51 | + exit('problem with book uniqueness'); |
|
| 52 | + } |
|
| 53 | + $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $query = " |
@@ -61,20 +61,20 @@ discard block |
||
| 61 | 61 | $statement = $pdo->prepare($query); |
| 62 | 62 | $statement->execute(); |
| 63 | 63 | while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { |
| 64 | - $query = " |
|
| 64 | + $query = " |
|
| 65 | 65 | SELECT `activity`.`id` |
| 66 | 66 | FROM `jpemeric_stream`.`activity` |
| 67 | 67 | INNER JOIN `jpemeric_stream`.`dailymile` ON `dailymile`.`id` = `activity`.`type_id` AND |
| 68 | 68 | `dailymile`.`entry_id` = :entry_id |
| 69 | 69 | WHERE `activity`.`type` = 'distance'"; |
| 70 | - $entryId = $row['url']; |
|
| 71 | - $entryId = explode('/', $entryId); |
|
| 72 | - $entryId = end($entryId); |
|
| 73 | - $updateRecords = $pdo->fetchAll($query, ['entry_id' => $entryId]); |
|
| 74 | - if (count($updateRecords) !== 1) { |
|
| 75 | - exit('problem with distance uniqueness'); |
|
| 76 | - } |
|
| 77 | - $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 70 | + $entryId = $row['url']; |
|
| 71 | + $entryId = explode('/', $entryId); |
|
| 72 | + $entryId = end($entryId); |
|
| 73 | + $updateRecords = $pdo->fetchAll($query, ['entry_id' => $entryId]); |
|
| 74 | + if (count($updateRecords) !== 1) { |
|
| 75 | + exit('problem with distance uniqueness'); |
|
| 76 | + } |
|
| 77 | + $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $query = " |
@@ -85,21 +85,21 @@ discard block |
||
| 85 | 85 | $statement = $pdo->prepare($query); |
| 86 | 86 | $statement->execute(); |
| 87 | 87 | while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { |
| 88 | - $query = " |
|
| 88 | + $query = " |
|
| 89 | 89 | SELECT `activity`.`id` |
| 90 | 90 | FROM `jpemeric_stream`.`activity` |
| 91 | 91 | INNER JOIN `jpemeric_stream`.`twitter2` ON `twitter2`.`id` = `activity`.`type_id` AND |
| 92 | 92 | `twitter2`.`tweet_id` = :tweet_id |
| 93 | 93 | WHERE `type` = 'twitter'"; |
| 94 | - $updateRecords = $pdo->fetchAll($query, ['tweet_id' => $row['twitter_id']]); |
|
| 95 | - if (count($updateRecords) !== 1) { |
|
| 96 | - if (count($updateRecords) === 0) { |
|
| 97 | - echo 'Could not find match for id: ', $row['twitter_id'], PHP_EOL; |
|
| 98 | - continue; |
|
| 99 | - } |
|
| 100 | - exit('problem with twitter uniqueness'); |
|
| 101 | - } |
|
| 102 | - $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 94 | + $updateRecords = $pdo->fetchAll($query, ['tweet_id' => $row['twitter_id']]); |
|
| 95 | + if (count($updateRecords) !== 1) { |
|
| 96 | + if (count($updateRecords) === 0) { |
|
| 97 | + echo 'Could not find match for id: ', $row['twitter_id'], PHP_EOL; |
|
| 98 | + continue; |
|
| 99 | + } |
|
| 100 | + exit('problem with twitter uniqueness'); |
|
| 101 | + } |
|
| 102 | + $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $query = " |
@@ -109,26 +109,26 @@ discard block |
||
| 109 | 109 | $statement = $pdo->prepare($query); |
| 110 | 110 | $statement->execute(); |
| 111 | 111 | while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { |
| 112 | - $query = " |
|
| 112 | + $query = " |
|
| 113 | 113 | SELECT `activity`.`id` |
| 114 | 114 | FROM `jpemeric_stream`.`activity` |
| 115 | 115 | WHERE `activity`.`type` = 'youtube' AND `activity`.`type_id` = :type_id"; |
| 116 | - $updateRecords = $pdo->fetchAll($query, ['type_id' => $row['type_id']]); |
|
| 117 | - if (count($updateRecords) != 1) { |
|
| 118 | - if (count($updateRecords) === 0) { |
|
| 119 | - echo "could not find match for youtube {$row['type_id']}", PHP_EOL; |
|
| 120 | - continue; |
|
| 121 | - } |
|
| 122 | - exit('problem with youtube uniqueness'); |
|
| 123 | - } |
|
| 124 | - $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 116 | + $updateRecords = $pdo->fetchAll($query, ['type_id' => $row['type_id']]); |
|
| 117 | + if (count($updateRecords) != 1) { |
|
| 118 | + if (count($updateRecords) === 0) { |
|
| 119 | + echo "could not find match for youtube {$row['type_id']}", PHP_EOL; |
|
| 120 | + continue; |
|
| 121 | + } |
|
| 122 | + exit('problem with youtube uniqueness'); |
|
| 123 | + } |
|
| 124 | + $idMap[current($updateRecords)['id']] = $row['id']; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | foreach ($idMap as $currentId => $newId) { |
| 128 | - $query = " |
|
| 128 | + $query = " |
|
| 129 | 129 | UPDATE `activity` SET `id` = :new_id WHERE `id` = :current_id"; |
| 130 | - $update = $pdo->perform($query, ['new_id' => $newId, 'current_id' => $currentId]); |
|
| 131 | - if ($update === false) { |
|
| 132 | - exit('problem with update'); |
|
| 133 | - } |
|
| 130 | + $update = $pdo->perform($query, ['new_id' => $newId, 'current_id' => $currentId]); |
|
| 131 | + if ($update === false) { |
|
| 132 | + exit('problem with update'); |
|
| 133 | + } |
|
| 134 | 134 | } |