yii\mongodb\Query::all PHP Method

all() public method

Executes the query and returns all results as an array.
public all ( Connection $db = null ) : array
$db Connection the Mongo connection used to execute the query. If this parameter is not given, the `mongodb` application component will be used.
return array the query results. If the query results in nothing, an empty array will be returned.
    public function all($db = null)
    {
        $cursor = $this->buildCursor($db);
        $rows = $this->fetchRows($cursor, true, $this->indexBy);
        return $this->populate($rows);
    }

Usage Example

Exemplo n.º 1
0
 public function actionRegister()
 {
     //get request
     $postData = file_get_contents('php://input', true);
     $data = json_decode($postData, true);
     $mobile = $data['data']['phone'];
     Yii::getLogger()->log($data['data'], 2, "webhook");
     //send sms
     if ($mobile != null && $mobile != '') {
         $reminder = new Reminder();
         $createDate = time();
         $reminder->mobile = $mobile;
         $reminder->createDate = $createDate;
         $reminder->updated = false;
         $reminder->origin = 'webhook';
         $reminder->save();
         $rid = $reminder->_id . '';
         $reminder->url = $this->replaceHttp(Yii::$app->request->hostInfo) . "/user/reset_password/" . $rid;
         Yii::getLogger()->log($reminder->url, 2, "webhookUrl");
         $reminder->save();
         $name = null;
         $qry = new Query();
         $qry->from('reward');
         $list = $qry->all();
         if ($list != null && count($list) > 0) {
             $name = $list[0]['name'];
         }
         if ($name == null) {
             $name = "\$25聖安娜蛋糕禮券";
         }
         $content = "恭喜您參加家樂牌「儲分有賞」活動。您的帳戶已建立,立即按連結重設密碼並登入,即可查詢分數並有機會獲得" . $name . "!\n" . $reminder->url;
         Yii::getLogger()->log($content, 2, "content");
         Yii::$app->sms->sendSms($reminder->mobile, $content);
     }
 }
All Usage Examples Of yii\mongodb\Query::all