當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mapper::insert方法代碼示例

本文整理匯總了PHP中Mapper::insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mapper::insert方法的具體用法?PHP Mapper::insert怎麽用?PHP Mapper::insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mapper的用法示例。


在下文中一共展示了Mapper::insert方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: insertPicture

 /**
  * 
  * @param Picture $picture_
  * @param array $arrayFilter
  * @throws InvalidArgumentException
  */
 public function insertPicture(Picture $picture_, array $arrayFilter = array(), $unitary = false)
 {
     try {
         if (is_null($this->table)) {
             throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
         }
         if (isset($unitary) && $unitary) {
             if (isset($this->files) && !empty($this->files) && count($this->files) == 1) {
                 foreach ($this->files as $file) {
                     $picture = initObject($file, $picture_, true, false);
                     $pictureExt = substr(strrchr($picture->getType(), "/"), 1);
                     $picture->setPath('/announcement/original/');
                     $picture->setTitle(uniqid());
                     $picture->setExtension($pictureExt);
                     if ($this->insertPicture($picture, array('tmp_name', 'size', 'type'))) {
                         move_uploaded_file($picture->getTmpName(), UPLOAD_PATH . '/announcement/original/' . $picture_->getTitle() . '.' . $picture->getExtension());
                     }
                 }
             }
         }
         return parent::insert($this->table, $picture_, $arrayFilter);
     } catch (InvalidArgumentException $e) {
         print $e->getMessage();
         exit;
     }
 }
開發者ID:noxa02,項目名稱:REST_ANNONCE,代碼行數:32,代碼來源:PictureMapper.class.php

示例2: insertMessage

 /**
  * 
  * @param Message $message_
  * @param array $arrayFilter
  * @throws InvalidArgumentException
  */
 public function insertMessage(Message $message_, array $arrayFilter = array())
 {
     try {
         if (is_null($this->table)) {
             throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
         }
         $userMapper = new UserMapper();
         $userMapper->setId($message_->getIdSender());
         $user_sender = $userMapper->selectUser();
         $userMapper->setId($message_->getIdReceiver());
         $user_receiver = $userMapper->selectUser();
         if (!is_null($user_sender->getId()) && !is_null($user_receiver->getId())) {
             return parent::insert($this->table, $message_, $arrayFilter);
         } elseif (is_null($user_sender->getId())) {
             throw new Exception('User sender does not exist !');
         } elseif (is_null($user_receiver->getId())) {
             throw new Exception('User receiver does not exist !');
         }
     } catch (InvalidArgumentException $e) {
         print $e->getMessage();
         exit;
     } catch (Exception $e) {
         print $e->getMessage();
         exit;
     }
 }
開發者ID:noxa02,項目名稱:REST_ANNONCE,代碼行數:32,代碼來源:MessageMapper.class.php

示例3: insertComment

 /**
  * 
  * @param Comment $comment_
  * @param array $arrayFilter
  * @throws InvalidArgumentException
  */
 public function insertComment(Comment $comment_, array $arrayFilter = array())
 {
     try {
         if (is_null($this->table)) {
             throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
         }
         $userMapper = new UserMapper();
         $announcementMapper = new AnnouncementMapper();
         $userMapper->setId($comment_->getIdUser());
         $user = $userMapper->selectUser();
         $announcementMapper->setId($comment_->getIdAnnouncement());
         $announcement = $announcementMapper->selectAnnouncement();
         if (!is_null($user->getId()) && !is_null($announcement->getId())) {
             return parent::insert($this->table, $comment_, $arrayFilter);
         } elseif (is_null($user->getId())) {
             throw new Exception('User is inexistant !');
         } elseif (is_null($announcement->getId())) {
             throw new Exception('Announcement is inexistant !');
         }
     } catch (InvalidArgumentException $e) {
         print $e->getMessage();
         exit;
     } catch (Exception $e) {
         print $e->getMessage();
         exit;
     }
 }
開發者ID:noxa02,項目名稱:REST_ANNONCE,代碼行數:33,代碼來源:CommentMapper.class.php

示例4: insertTag

 /**
  * 
  * @param Tag $tag_
  * @param array $arrayFilter
  * @throws InvalidArgumentException
  */
 public function insertTag(Tag $tag_, array $arrayFilter = array())
 {
     try {
         if (is_null($this->table)) {
             throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
         }
         return parent::insert($this->table, $tag_, $arrayFilter);
     } catch (InvalidArgumentException $e) {
         print $e->getMessage();
         exit;
     }
 }
開發者ID:noxa02,項目名稱:REST_ANNONCE,代碼行數:18,代碼來源:TagMapper.class.php

示例5: insertIncoming

 /**
  * 
  * @param Incoming $incoming_
  * @param array $arrayFilter
  * @throws InvalidArgumentException
  */
 public function insertIncoming(Incoming $incoming_, array $arrayFilter = array())
 {
     try {
         if (is_null($this->table)) {
             throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
         }
         $userMapper = new UserMapper();
         $userMapper->setId($incoming_->getIdUser());
         $user = $userMapper->selectUser();
         if (!is_null($user->getId())) {
             return parent::insert($this->table, $incoming_, $arrayFilter);
         } elseif (isset($user) && is_null($user->getId())) {
             throw new Exception('User does not exist !');
         }
     } catch (Exception $e) {
         print $e->getMessage();
         exit;
     }
 }
開發者ID:noxa02,項目名稱:REST_ANNONCE,代碼行數:25,代碼來源:IncomingMapper.class.php

示例6: register

 /**
  * Register a new tag into tag holder
  *
  * @param Tag $tag The tag
  *
  * @return bool Return true when succeed, or throw a Exception for false
  */
 public function register(Tag $tag)
 {
     return Mapper::insert($this->tagMap, $tag->getTag(), $tag);
 }
開發者ID:raincious,項目名稱:facula,代碼行數:11,代碼來源:Tags.php

示例7: goAssociate

 public function goAssociate(stdClass $object_)
 {
     try {
         if (isset($object_) && !emptyObject($object_)) {
             $announcementMapper = new AnnouncementMapper();
             $announcementMapper->setId($object_->id_announcement);
             $announcement = $announcementMapper->selectAnnouncement();
             $tagMapper = new TagMapper();
             $tagMapper->setId($object_->id_tag);
             $tag = $tagMapper->selectTag();
             if (!is_null($announcement->getId()) && !is_null($tag->getId())) {
                 if (is_null($user->getId())) {
                     return parent::insert('TO_ASSOCIATE', $object_);
                 } else {
                     throw new Exception('The user is already followed by this user !');
                 }
                 return parent::insert($this->table, $message_, $arrayFilter);
             } elseif (is_null($announcement->getId())) {
                 throw new Exception('Announcement is inexistant !');
             } elseif (is_null($tag->getId())) {
                 throw new Exception('Tag is inexistant !');
             }
         } elseif (empty($id_announcement_)) {
             throw new Exception('Id announcement is required !');
         } elseif (empty($id_tag_)) {
             throw new Exception('Id tag is required !');
         }
     } catch (Exception $e) {
         print $e->getMessage();
         exit;
     }
 }
開發者ID:noxa02,項目名稱:REST_ANNONCE,代碼行數:32,代碼來源:AnnouncementMapper.class.php


注:本文中的Mapper::insert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。