【发布时间】:2016-04-10 16:21:14
【问题描述】:
我的项目是用 Laravel4 和 mongoDB 创建的。
我使用 laravel artisan 创建了一个命令,并在 Laravel 中使用此命令 php artisan taxi:checktrips 进行检查。 Laravel 中的这个命令运行:
public function schedule(Schedulable $scheduler)
{
return $scheduler->everyMinutes(.06);
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
while (true) {
try {
sleep(2);
foreach ($this->redis->keys('trip_id*') as $key) {
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
if ($this->driver->closest($trip_id)) {
echo 'Closest, Add trip_temp_id Redis';
$this->redis->set('trip_temp_id|'.$trip_id,
(int) $this->redis->get($key));
Log::importRedis('trip_temp_id|'.$trip_id, $trip_id);
}
echo "{$trip_id}, Deleted Redis";
$this->redis->del($key);
Log::exportRedis($key, $trip_id);
}
foreach ($this->redis->keys('trip_temp_id*') as $key) {
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
if (\Carbon\Carbon::now()->timestamp > (int) $this->redis->get($key)) {
echo 'Deleting Temp Redis';
$this->redis->del($key);
Log::exportRedis($key, $trip_id);
$this->driver->rejectTrip($trip_id);
}
}
} catch (\Exception $e) {
Log::errorLog([
'file' => $e->getFile(),
'line' => $e->getLine(),
'code' => $e->getCode(),
'message' => $e->getMessage(),
'trace' => $e->getTrace(),
'trace_string' => $e->getTraceAsString(),
'previous' => $e->getPrevious(),
]);
}
}
}
}
但是当我执行时显示:
[MongoException]
zero-length keys are not allowed, did you use $ with double quotes?
我怎样才能修复它以运行没有任何问题?
【问题讨论】:
标签: php mongodb laravel laravel-4 laravel-artisan