Beispiel #1
0
 /**
  * Set propel to be used later
  *
  * @return void
  */
 public static function setupPropel()
 {
     $serviceContainer = new StandardServiceContainer();
     Propel::setServiceContainer($serviceContainer);
     $config = Helper::getConfig();
     $dbConfig = $config['database'];
     $manager = self::setPropelManager($dbConfig);
     self::setPropelServiceContainer($serviceContainer, $dbConfig, $manager);
 }
Beispiel #2
0
 public function run()
 {
     $config = HelperTool::getConfig();
     $this->processMaxRetryTimeBeforeContinue = isset($config['process']['maxRetryTimeBeforeContinue']) ? $config['process']['maxRetryTimeBeforeContinue'] : (int) ($this->maxProcesses * 0.03) + self::MAX_RETRY_TIME_BEFORE_CONTINUE;
     $currentRunningProcessesCount = (int) $this->getCurrentRunningProcesses();
     $numberOfThreadsToCreate = $this->maxProcesses - $currentRunningProcessesCount;
     for ($i = 0; $i < $numberOfThreadsToCreate; $i++) {
         $pid = pcntl_fork();
         switch ($pid) {
             case -1:
                 continue;
                 break;
             case 0:
                 $this->doJob();
                 // Exit the current child
                 exit;
                 break;
             default:
                 // Parent do nothing, just create another child
                 break;
         }
     }
 }
Beispiel #3
0
 private function processQueryAndSetEntities($sql)
 {
     $config = Helper::getConfig();
     $tableReference = $config['repository']['tableReference'];
     $search = array_keys($tableReference);
     $replace = array_values($tableReference);
     $sql = str_replace($search, $replace, $sql);
     $pdo = new \PDO($config['database']['dsn'], $config['database']['username'], $config['database']['password']);
     $stmt = $pdo->prepare($sql);
     $stmt->setFetchMode(\PDO::FETCH_ASSOC);
     $stmt->execute();
     $result = $stmt->fetchAll();
     $mapper = DbMapperFactory::make('task|pdo|entity');
     $mapper->setArrays($result);
     $this->setEntitiesFromResponse($mapper->getMappedFirstEntities());
 }