/** * This function performs a new insertion of this object's data into the DB. It is the implementing * class's responsibilty to set the newly generated DB id after insertion, (this is due to synchronicity * dependencies which may arise from potential insertions of child objects). * @param PDO $dbConnection The database connection this object will utilize to process * the insertion. * @return void * @throws Excetpion If an error is encountered in the process, an exception will be thrown. */ protected function insert(PDO $dbConnection) { $preparedStatement = $dbConnection->prepare('INSERT INTO user_preferences ( user_id ) VALUES ( :userid )'); $userId = $this->getUserId(); $preparedStatement->bindParam(':userid', $userId); $preparedStatement->execute(); parent::setId($dbConnection->lastInsertId()); $preparedStatement = NULL; }
protected function insert(PDO $dbConnection) { $preparedStatement = $dbConnection->prepare('INSERT INTO image_attribute ( image_data_id, attribute ) VALUES ( :imageDataId, :attribute )'); $imageDataId = $this->getImageDataId(); $preparedStatement->bindParam(':imageDataId', $imageDataId); $attribute = $this->getAttribute(); $preparedStatement->bindParam(':attribute', $attribute); $preparedStatement->execute(); parent::setId($dbConnection->lastInsertId()); $preparedStatement = NULL; }
protected function insert(PDO $dbConnection) { $preparedStatement = $dbConnection->prepare('INSERT INTO journey ( title, comments, creation_date ) VALUES( :title, :comments, :creationDate )'); $title = $this->getTitle(); $preparedStatement->bindParam(':title', $title); $comments = $this->getComments(); $preparedStatement->bindParam(':comments', $comments); $creationDate = date('Y-m-d H:i:s', $this->getCreationDate()); $preparedStatement->bindParam(':creationDate', $creationDate); $preparedStatement->execute(); parent::setId($dbConnection->lastInsertId()); $preparedStatement = NULL; $preparedStatement = $dbConnection->prepare('INSERT INTO journey_image_data_assoc ( journey_id, image_data_id ) VALUES( :journeyId, :imageDataId )'); foreach ($this->imageIdList as $imageId) { $preparedStatement->bindParam(':journeyId', parent::getId()); $preparedStatement->bindParam(':imageDataId', $imageId); $preparedStatement->execute(); } $preparedStatement = NULL; }
protected function insert(PDO $dbConnection) { $preparedStatement = $dbConnection->prepare('INSERT INTO metadata_template ( species, staining_method, author, brain_region, antibody, comments, content_type, template_name ) VALUES ( :species, :stainingMethod, :author, :brainRegion, :antibody, :comments, :contentType, :templateName )'); $species = $this->getSpecies(); $preparedStatement->bindParam(':species', $species); $stainingMethod = $this->getStainingMethod(); $preparedStatement->bindParam(':stainingMethod', $stainingMethod); $author = $this->getAuthor(); $preparedStatement->bindParam(':author', $author); $brainRegion = $this->getBrainRegion(); $preparedStatement->bindParam(':brainRegion', $brainRegion); $antibody = $this->getAntibody(); $preparedStatement->bindParam(':antibody', $antibody); $comments = $this->getComments(); $preparedStatement->bindParam(':comments', $comments); $contentType = $this->getContentType(); $preparedStatement->bindParam(':contentType', $contentType); $templateName = $this->getTemplateName(); $preparedStatement->bindParam(':templateName', $templateName); $preparedStatement->execute(); $preparedStatement = NULL; parent::setId($dbConnection->lastInsertId()); }
/** * This function performs a new insertion of this object's data into the DB. It is the implementing * class's responsibilty to set the newly generated DB id after insertion, (this is due to synchronicity * dependencies which may arise from potential insertions of child objects). * @param PDO $dbConnection The database connection this object will utilize to process * the insertion. * @return void * @throws Excetpion If an error is encountered in the process, an exception will be thrown. */ protected function insert(PDO $dbConnection) { // insert the new user data $preparedStatement = $dbConnection->prepare('INSERT INTO user ( username, password, email, enabled ) VALUES ( :username, :password, :email, :enabled )'); $username = $this->getUsername(); $preparedStatement->bindParam(':username', $username); $password = $this->getPassword(); $preparedStatement->bindParam(':password', $password); $email = $this->getEmail(); $preparedStatement->bindParam(':email', $email); $isEnabled = $this->isEnabled(); $preparedStatement->bindParam(':enabled', $isEnabled); $preparedStatement->execute(); parent::setId($dbConnection->lastInsertId()); $preparedStatement = NULL; }
/** * This function performs a new insertion of this object's data into the DB. It is the implementing * class's responsibilty to set the newly generated DB id after insertion, (this is due to synchronicity * dependencies which may arise from potential insertions of child objects). * @param PDO $dbConnection The database connection this object will utilize to process * the insertion. * @return void * @throws Excetpion If an error is encountered in the process, an exception will be thrown. */ protected function insert(PDO $dbConnection) { $preparedStatement = $dbConnection->prepare('INSERT INTO image_data ( submitter_user_id, content_uri, thumbnail_uri, author, title, year ) VALUES ( :submitteruserid, :contenturi, :thumbnail, :author, :title, :year )'); $submitterUserId = $this->getSubmitterUserId(); $preparedStatement->bindParam(':submitteruserid', $submitterUserId); $contentUri = $this->getContentUri(); $preparedStatement->bindParam(':contenturi', $contentUri); $thumbnailUri = $this->getThumbnailUri(); $preparedStatement->bindParam(':thumbnail', $thumbnailUri); $author = $this->getAuthor(); $preparedStatement->bindParam(':author', $author); $title = $this->getTitle(); $preparedStatement->bindParam(':title', $title); $year = $this->getYear(); $preparedStatement->bindParam(':year', $year); $preparedStatement->execute(); $preparedStatement = NULL; parent::setId($dbConnection->lastInsertId()); foreach ($this->attributeList as $attribute) { $attribute->setImageDataId(parent::getId()); $attribute->save($dbConnection); } }