/**
  * Saves the pool to the database.
  *
  * @param \MusicBox\Entity\Like $pool
  */
 public function save($pool)
 {
     $poolData = array('address_id' => $pool->getAddress()->getId(), 'access_info' => $pool->getAccessInfo());
     if ($pool->getId()) {
         $this->db->update('pools', $poolData, array('pool_id' => $pool->getId()));
         $newFile = $this->handleFileUpload($item);
         if ($newFile) {
             $poolData['image'] = $pool->getImage();
         }
     } else {
         // The pool is new, note the creation timestamp.
         $poolData['created_at'] = time();
         $this->db->insert('pools', $poolData);
         // Get the id of the newly created pool and set it on the entity.
         $id = $this->db->lastInsertId();
         $pool->setId($id);
         // If a new image was uploaded, update the pool with the new
         // filename.
         $newFile = $this->handleFileUpload($pool);
         if ($newFile) {
             $newData = array('image' => $pool->getImage());
             $this->db->update('pools', $newData, array('pool_id' => $id));
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Saves the like to the database.
  *
  * @param \MusicBox\Entity\Like $like
  */
 public function save($like)
 {
     $likeData = array('artist_id' => $like->getArtist()->getId(), 'user_id' => $like->getUser()->getId());
     if ($like->getId()) {
         $this->db->update('likes', $likeData, array('like_id' => $like->getId()));
     } else {
         // The like is new, note the creation timestamp.
         $likeData['created_at'] = time();
         $this->db->insert('likes', $likeData);
         // Get the id of the newly created like and set it on the entity.
         $id = $this->db->lastInsertId();
         $like->setId($id);
     }
 }
 /**
  * Saves the group to the database.
  *
  * @param \MusicBox\Entity\Like $group
  */
 public function save($group)
 {
     $groupData = array('artist_id' => $group->getArtist()->getId(), 'user_id' => $group->getUser()->getId());
     if ($group->getId()) {
         $this->db->update('groups', $groupData, array('group_id' => $group->getId()));
     } else {
         // The group is new, note the creation timestamp.
         $groupData['created_at'] = time();
         $this->db->insert('groups', $groupData);
         // Get the id of the newly created group and set it on the entity.
         $id = $this->db->lastInsertId();
         $group->setId($id);
     }
 }
 /**
  * Saves the lesson to the database.
  *
  * @param \MusicBox\Entity\Like $lesson
  */
 public function save($lesson)
 {
     $lessonData = array('user_id' => $lesson->getUser()->getId());
     if ($lesson->getId()) {
         $this->db->update('lessons', $lessonData, array('lesson_id' => $lesson->getId()));
     } else {
         // The lesson is new, note the creation timestamp.
         $lessonData['created_at'] = time();
         $this->db->insert('lessons', $lessonData);
         // Get the id of the newly created lesson and set it on the entity.
         $id = $this->db->lastInsertId();
         $lesson->setId($id);
     }
 }
 /**
  * Saves the address to the database.
  *
  * @param \MusicBox\Entity\Like $address
  */
 public function save($address)
 {
     $addressData = array('user_id' => $address->getUserId(), 'street' => $address->getStreet(), 'street2' => $address->getStreet2(), 'city' => $address->getCity(), 'state' => $address->getState(), 'zip' => $address->getZip(), 'billing' => $address->getType());
     if ($address->getId()) {
         try {
             $this->db->update('addresses', $addressData, array('address_id' => $address->getId()));
         } catch (\Exception $e) {
             return false;
         }
     } else {
         // The address is new, note the creation timestamp.
         try {
             $this->db->insert('addresses', $addressData);
             // Get the id of the newly created address and set it on the entity.
             $id = $this->db->lastInsertId();
             $address->setAddressId($id);
         } catch (\Exception $e) {
             dump($e);
             exit;
             return false;
         }
     }
 }