/**
  *  findInboxes option
  *  @return objects or record total
  */
 protected function findInboxesReal($opt = [], $isGetCount = false)
 {
     // validate 欄位 白名單
     $list = ['fields' => ['id' => 'id', 'parentId' => 'parent_id', 'fromEmail' => 'from_email', 'toEmail' => 'to_email', 'fromName' => 'from_name', 'toName' => 'to_name', 'subject' => 'subject', 'bodySnippet' => 'body_snippet', 'emailCreateTime' => 'email_create_time', 'messageId' => 'message_id', 'referenceMessageIds' => 'reference_message_ids'], 'option' => ['_order', '_page', '_itemsPerPage']];
     ZendModelWhiteListHelper::validateFields($opt, $list);
     ZendModelWhiteListHelper::filterOrder($opt, $list);
     ZendModelWhiteListHelper::fieldValueNullToEmpty($opt);
     $select = $this->getDbSelect();
     $field = $list['fields'];
     if (isset($opt['parentId'])) {
         $select->where->and->equalTo($field['parentId'], $opt['parentId']);
     }
     if (isset($opt['fromEmail'])) {
         $select->where->and->equalTo($field['fromEmail'], $opt['fromEmail']);
     }
     if (isset($opt['toEmail'])) {
         $select->where->and->equalTo($field['toEmail'], $opt['toEmail']);
     }
     if (isset($opt['fromName'])) {
         $select->where->and->equalTo($field['fromName'], $opt['fromName']);
     }
     if (isset($opt['toName'])) {
         $select->where->and->equalTo($field['toName'], $opt['toName']);
     }
     if (isset($opt['subject'])) {
         $select->where->and->like($field['subject'], '%' . $opt['subject'] . '%');
     }
     if (isset($opt['bodySnippet'])) {
         $select->where->and->like($field['bodySnippet'], '%' . $opt['bodySnippet'] . '%');
     }
     if (isset($opt['messageId'])) {
         $select->where->and->equalTo($field['messageId'], $opt['messageId']);
     }
     if (isset($opt['referenceMessageIds'])) {
         $select->where->and->like($field['referenceMessageIds'], '%' . $opt['referenceMessageIds'] . '%');
     }
     if (!$isGetCount) {
         return $this->findObjects($select, $opt);
     }
     return $this->numFindObjects($select);
 }
Beispiel #2
0
 /**
  *  findMessages option
  *  @return objects or record total
  */
 protected function findMessagesReal($opt = [], $isGetCount = false)
 {
     // validate 欄位 白名單
     $list = ['fields' => ['id' => 'id', 'messageId' => 'message_id', 'updateId' => 'update_id', 'userId' => 'user_id', 'firstName' => 'first_name', 'lastName' => 'last_name', 'chatType' => 'chat_type', 'chatId' => 'chat_id', 'chatTitle' => 'chat_title', 'content' => 'content', 'createMessageTime' => 'create_message_time', 'isUsed' => 'is_used', 'properties' => 'properties'], 'option' => ['_order', '_page', '_itemsPerPage']];
     ZendModelWhiteListHelper::validateFields($opt, $list);
     ZendModelWhiteListHelper::filterOrder($opt, $list);
     ZendModelWhiteListHelper::fieldValueNullToEmpty($opt);
     $select = $this->getDbSelect();
     $field = $list['fields'];
     if (isset($opt['id'])) {
         $select->where->and->equalTo($field['id'], $opt['id']);
     }
     if (isset($opt['messageId'])) {
         $select->where->and->equalTo($field['messageId'], $opt['messageId']);
     }
     if (isset($opt['updateId'])) {
         $select->where->and->equalTo($field['updateId'], $opt['updateId']);
     }
     if (isset($opt['userId'])) {
         $select->where->and->equalTo($field['userId'], $opt['userId']);
     }
     if (isset($opt['firstName'])) {
         $select->where->and->equalTo($field['firstName'], $opt['firstName']);
     }
     if (isset($opt['lastName'])) {
         $select->where->and->equalTo($field['lastName'], $opt['lastName']);
     }
     if (isset($opt['chatType'])) {
         $select->where->and->equalTo($field['chatType'], $opt['chatType']);
     }
     if (isset($opt['chatId'])) {
         $select->where->and->equalTo($field['chatId'], $opt['chatId']);
     }
     if (isset($opt['chatTitle'])) {
         $select->where->and->equalTo($field['chatTitle'], $opt['chatTitle']);
     }
     if (isset($opt['content'])) {
         $select->where->and->like($field['content'], '%' . $opt['content'] . '%');
     }
     if (isset($opt['isUsed'])) {
         $select->where->and->equalTo($field['isUsed'], $opt['isUsed']);
     }
     if (!$isGetCount) {
         return $this->findObjects($select, $opt);
     }
     return $this->numFindObjects($select);
 }