Exemple #1
0
 /**
  *
  * @param type $entry
  * @return type $last_inserted_id (the ID generated in the last query)
  */
 public function addEntry($entry)
 {
     $trm = new TranslationRequestManager();
     $id = $entry->getEntryId();
     $langid = $entry->getEntryLanguageId();
     $text = $entry->getEntryText();
     // 1
     // TODO: create the verbatim of $text using the Bing translator
     $verbatim = $entry->getEntryVerbatim();
     // 2
     // TODO: transliterate the value of $text using ...
     $translit = $entry->getEntryTranslit();
     // 3
     $authen = $entry->getEntryAuthenStatusId();
     // 4
     $translOf = $entry->getEntryTranslOf();
     // 5
     $userId = $entry->getEntryUserId();
     // 6
     $mediaId = $entry->getEntryMediaId();
     // 7
     $commentId = $entry->getEntryCommentId();
     // 8
     $ratingId = $entry->getEntryRatingId();
     // 9
     $tags = $entry->getEntryTags();
     //10
     //$authorId =   $entry->getEntryAuthorId(); // 11
     $authors = $entry->getEntryAuthors();
     $sourceId = $entry->getEntrySourceId();
     // 12
     $use = $entry->getEntryUse();
     // 13
     $link = $entry->getEntryHttpLink();
     // 14
     $date = $entry->getEntryCreationDate();
     // 15
     $query_insert = 'INSERT INTO ' . ENTRY . ' (' . '`ent_entry_language_id`, ' . '`ent_entry_text`, ' . '`ent_entry_verbatim`, ' . '`ent_entry_translit`, ' . '`ent_entry_authen_status_id`, ' . '`ent_entry_translation_of`, ' . '`ent_entry_creator_id`, ' . '`ent_entry_media_id`, ' . '`ent_entry_comment_id`, ' . '`ent_entry_rating_id`, ' . '`ent_entry_tags`, ' . '`ent_entry_authors`, ' . '`ent_entry_source_id`, ' . '`ent_entry_use`, ' . '`ent_entry_http_link`, ' . '`ent_entry_creation_date`)' . ' VALUES(' . '"' . $langid . '", "' . $text . '", "' . $verbatim . '", "' . $translit . '", ' . $authen . ', "' . $translOf . '", "' . $userId . '", "' . $mediaId . '", "' . $commentId . '", "' . $ratingId . '", "' . $tags . '", "' . $authors . '", "' . $sourceId . '", "' . $use . '", "' . $link . '", "' . $date . '")';
     // 51
     //echo "<br>eda::query_insert:<br>"; echo $query_insert;
     $dbHelper = new DBHelper();
     // 18
     $last_inserted_id = $dbHelper->executeInsertQuery($query_insert);
     // 17
     //16
     //..............................................................
     // if this is a kid, delete the treq for its dad if exists
     if (!null == $translOf) {
         // if the entry being created has a dad (i.e. is a kid)
         //echo "<br>eda::translOf = " . $translOf;
         // look into the treq table, see if there's a treq for this entry and for this $langid
         $treq = $trm->getTreqAllColumnsByEntryIdAndLangId($translOf, $langid);
         $treq_id = $treq->getTreqId();
         $treq_entry_id = $treq->getTreqEntryId();
         //$treq_lang_id = $treq->getTreqLangId();
         //echo "<br>eda::AddEntry - treq id = " . $treq_id;
         //echo "<br>eda::AddEntry - treq entry id = " . $treq_entry_id;
         //echo "<br>eda::AddEntry - treq lang id = " . $treq_lang_id;
         // if there is/are, delete it/them
         if (!null == $treq_entry_id) {
             $treq_delete_sql = 'DELETE FROM ' . TRANS_REQUEST . ' WHERE treq_id = ' . $treq_id . ';';
             //echo "<br>eda::AddEntry - treq delete sql = " . $treq_delete_sql;
             $dbHelper->executeQuery($treq_delete_sql);
         }
     }
     //..............................................................
     return $last_inserted_id;
 }