mongodb - Find a mail with a status and compare date scheduled with now (MONGO/PHP) -


i have little problem send mail. searching send many mails come db 2 conditons :

  • mail status 'to_send.
  • mail date scheduled.

these 2 conditions run in find request :

$mails = $database->mails->find(['status' => 'to_send', ['date_scheduled' => ['$gte' => new mongodb\bson\utcdatetime()]]]); 

find mails status good, when i'm adding scheduled condition have message :

fatal error: uncaught mongodb\driver\exception\invalidargumentexception: mongodb\bson\utcdatetime::__construct() expects 1 parameter, 0 given in /users/developpeur/cron/cron_mail.php:22 stack trace:

0 /users/developpeur/cron/cron_mail.php(22): mongodb\bson\utcdatetime->__construct()

1 {main}

thrown in /users/developpeur/cron/cron_mail.php on line 22

can me please?

the utcdatetime() constructor expects single parameter (the number of milliseconds since epoch). i'm no php expert, should able pass time() * 1000 parameter create mongodb utcdatetime current date/time. request this:

$mails = $database->mails->find(['status' => 'to_send', ['date_scheduled' => ['$gte' => new mongodb\bson\utcdatetime(time() * 1000)]]]); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -