/**
  * Create collections starting from a specific id, and
  * running until we are at the end
  *
  * @var $startingPoint int
  * @var $cb callable
  */
 public function createCollections($startingPoint, $cb)
 {
     $increment = 5000;
     /*
      * Create a faked parse search, so we can re-use existing infrastructure
      */
     $parsedSearch = array('sortFields' => array(array('field' => 'id', 'direction' => 'asc')), 'additionalJoins' => array(), 'additionalTables' => array(), 'additionalFields' => array());
     /*
      * Actually fetch the spots
      */
     $svcProvSpotList = new Services_Providers_SpotList($this->_daoFactory->getSpotDao());
     while (true) {
         if ($cb !== null) {
             $cb('start', $startingPoint, $increment);
         }
         // if
         /**
          * Get the current list of spots
          */
         $parsedSearch['filter'] = ' (s.id > ' . (int) $startingPoint . ') ' . ' AND (s.collectionid IS NULL) ' . ' AND (s.stamp > 1290578400)' . ' AND (s.category <> 2) ' . ' AND (s.category <> 3) ' . ' AND (NOT ((s.category = 0) AND (s.subcatz = \'z3|\')))' . ' AND (NOT ((s.category = 0) AND (s.subcatz = \'z0|\') AND (s.subcatd LIKE \'%d6|%\')))' . ' AND (NOT ((s.category = 0) AND (s.subcatz = \'z0|\') AND (s.subcatd = \'d13|\')))';
         # exclude music videos as well
         $dbSpotList = $svcProvSpotList->fetchSpotList(0, 0, $increment, $parsedSearch);
         $startingPoint += $increment;
         /*
          * Parse the spots and get an collection id for it
          */
         $dbSpotList['list'] = $this->createCollectionsFromList($dbSpotList['list']);
         if (empty($dbSpotList['list'])) {
             if ($cb !== null) {
                 $cb('finish', $startingPoint, $increment);
             }
             // if
             break;
         }
         // if
         /*
          * now update the database
          */
         $dbConnection = $this->_daoFactory->getConnection();
         $dbConnection->beginTransaction();
         foreach ($dbSpotList['list'] as $spot) {
             $dbConnection->exec('UPDATE spots SET collectionid = :collectionid WHERE messageid = :messageid', array(':collectionid' => array($spot['collectionid'], PDO::PARAM_INT), ':messageid' => array($spot['messageid'], PDO::PARAM_INT)));
         }
         // foreach
         $dbConnection->commit();
         if ($cb !== null) {
             $cb('finish', $startingPoint, $increment);
         }
         // if
     }
     // while
 }
 function __construct(Dao_Factory $daoFactory, Services_Settings_Container $settings)
 {
     $this->_dbCon = $daoFactory->getConnection();
     $this->_userDao = $daoFactory->getUserDao();
     $this->_settings = $settings;
 }
 function __construct(Dao_Factory $daoFactory, Services_Settings_Container $settings, $dbEngine)
 {
     $this->_daoFactory = $daoFactory;
     $this->_dbStruct = SpotStruct_abs::factory($dbEngine, $daoFactory->getConnection());
     $this->_settings = $settings;
 }