- Timestamp:
- 11/05/09 10:48:23 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/boonex/data_migration/classes/BxDataMigrationProfiles.php
r13104 r13145 110 110 createUserDataFile($iProfileId); 111 111 112 $this -> iTransffered++;113 114 112 // migrate profile's picture; 115 113 if($aRow['Picture'] && $this -> bAvatarInstalled) { 116 114 $this -> _exportAvatar($aRow['ID'], $iProfileId, $aRow['PrimPhoto']); 117 115 } 116 117 // migrate friends; 118 $sResult = $this -> _exportFriends($aRow['ID']); 119 if($sResult) { 120 return $sResult; 121 } 122 123 $this -> iTransffered++; 118 124 } 119 125 } … … 164 170 } 165 171 } 172 } 173 174 /** 175 * Export all profile's friends; 176 * 177 * @param $iProfileId integer; 178 * @return string - error message if needed; 179 */ 180 function _exportFriends($iProfileId) 181 { 182 $iProfileId = (int) $iProfileId; 183 184 $sQuery = "SELECT * FROM `FriendList` WHERE `ID` = {$iProfileId} OR `Profile` = {$iProfileId}"; 185 $rResult = mysql_query($sQuery, $this -> rOldDb); 186 187 while( $aRow = mysql_fetch_assoc($rResult) ) 188 { 189 if( !$this -> isFriendExisting($aRow['ID'], $aRow['Profile'])) { 190 // build query; 191 $sQuery = 192 " 193 INSERT INTO 194 `sys_friend_list` 195 SET 196 `ID` = '{$aRow['ID']}', 197 `Profile` = '{$aRow['Profile']}', 198 `Check` = '{$aRow['Check']}', 199 `When` = NOW() 200 "; 201 202 $iResult = (int) $this -> oMigrationModule -> _oDb -> query($sQuery); 203 if($iResult <= 0) { 204 return 'Database error. Cannot insert friend list in the database.'; 205 } 206 } 207 } 166 208 } 167 209 … … 215 257 return $this -> oMigrationModule -> _oDb -> getOne($sQuery) ? true : false; 216 258 } 259 260 /** 261 * Check friends pair; 262 * 263 * @param $iProfileId integer 264 * @param $iFriendId integer 265 * @return boolean - true if already existing 266 */ 267 function isFriendExisting($iProfileId, $iFriendId) 268 { 269 $iProfileId = (int) $iProfileId; 270 $iFriendId = (int) $iFriendId; 271 272 $sQuery = 273 " 274 SELECT 275 COUNT(*) 276 FROM 277 `sys_friend_list` 278 WHERE 279 ( 280 (`ID` = {$iProfileId} AND `Profile` = {$iFriendId}) 281 OR 282 (`ID` = {$iFriendId} AND `Profile` = {$iProfileId}) 283 ) 284 AND 285 `Check` = 1 286 "; 287 288 return $this -> oMigrationModule -> _oDb -> getOne($sQuery) ? true : false; 289 } 217 290 }
Note: See TracChangeset
for help on using the changeset viewer.