public static function connect() { $config = Config::get('mongo'); $hosts = 'mongodb://' . $config['hosts']; $m = new MongoClient($hosts, ['db' => $config['dbname'], 'readPreference' => MongoClient::RP_SECONDARY_PREFERRED, 'replicaSet' => $config['set'], 'username' => $config['user'], 'password' => $config['passwd'], 'w' => 'majority']); self::$connection = $m; self::$db = $m->selectDB($config['dbname']); return self::$db; }
private static function isItTime() { $interval = Config::get('google_api.checkInterval') * 60; $lastEntry = new FetchLogEntry(); $t = new DateTime('now', new DateTimeZone('Europe/Budapest')); $t = strtotime($t->format('Y-m-d H:i:s')); if ($lastEntry->last() !== false && $t - $lastEntry->created_at->sec > $interval) { return true; } return false; }