BxDataMigrationData.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /***************************************************************************
  3. * Dolphin Smart Community Builder
  4. * -------------------
  5. * begin : Mon Mar 23 2006
  6. * copyright : (C) 2007 BoonEx Group
  7. * website : http://www.boonex.com
  8. * This file is part of Dolphin - Smart Community Builder
  9. *
  10. * Dolphin is free software; you can redistribute it and/or modify it under
  11. * the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the
  13. * License, or any later version.
  14. *
  15. * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  16. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. * See the GNU General Public License for more details.
  18. * You should have received a copy of the GNU General Public License along with Dolphin,
  19. * see license.txt file; if not, write to marketing@boonex.com
  20. ***************************************************************************/
  21. class BxDataMigrationData
  22. {
  23. var $oMigrationModule;
  24. var $rOldDb;
  25. var $oDolModule;
  26. /**
  27. * Class constructor;
  28. *
  29. * @param : $oMigrationModule (object) - object instance of migration class;
  30. * @param : $rOldDb (resourse) - connect to old dolphin's database;
  31. * @param : $oDolModule (object);
  32. * @return : void;
  33. */
  34. function BxDataMigrationData(&$oMigrationModule, &$rOldDb, $oDolModule = '')
  35. {
  36. $this -> oMigrationModule = $oMigrationModule;
  37. $this -> rOldDb = $rOldDb;
  38. $this -> oDolModule = $oDolModule ? $oDolModule : '';
  39. }
  40. /**
  41. * Function will migrate data;
  42. *
  43. * @return : (integer) operation result;
  44. */
  45. function getMigration()
  46. {
  47. $this -> setResultStatus('System error: method getMigration is not redefined');
  48. return MIGRATION_FAILED;
  49. }
  50. /**
  51. * Function set operation status;
  52. *
  53. * @return : void;
  54. */
  55. function setResultStatus($sStatus)
  56. {
  57. $sStatus = $this -> oMigrationModule -> _oDb -> escape($sStatus);
  58. $sQuery =
  59. "
  60. UPDATE
  61. `{$this -> oMigrationModule -> _oDb -> sTablePrefix}transfers`
  62. SET
  63. `status_text` = '{$sStatus}'
  64. WHERE
  65. `module` = '{$this -> oMigrationModule -> sProcessedModule}'
  66. ";
  67. $this -> oMigrationModule -> _oDb -> query($sQuery);
  68. }
  69. // shortcut to escape
  70. function escape($sText) {
  71. return $this->oMigrationModule->_oDb->escape($sText);
  72. }
  73. /**
  74. * Escape all strings values;
  75. *
  76. * @param $aRow array;
  77. * @return array - escaped data;
  78. */
  79. function escapeData($aRow)
  80. {
  81. foreach($aRow as $sKey => $mValue)
  82. {
  83. $aRow[$sKey] = !is_numeric($mValue)
  84. ? $this->escape($mValue)
  85. : $mValue;
  86. }
  87. return $aRow;
  88. }
  89. // shortcut to query
  90. function query($sQuery) {
  91. //echoDbg($sQuery); return;
  92. return $this->oMigrationModule->_oDb->query($sQuery);
  93. }
  94. // shortcut to getOne
  95. function getOne($sQuery) {
  96. return $this->oMigrationModule->_oDb->getOne($sQuery);
  97. }
  98. // shortcut to lastId
  99. function lastId() {
  100. return $this->oMigrationModule->_oDb->lastId();
  101. }
  102. }