/** * 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 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 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); } }