コード例 #1
0
ファイル: UserDataAccessor.php プロジェクト: kevin000/Tarboz
 public function addUser($user)
 {
     $dbHelper = new DBHelper();
     //All the data members are being passed through the escape string function
     $uid = $dbHelper->EscapeString($user->getUserId());
     $fname = $dbHelper->EscapeString($user->getFirstName());
     $lname = $dbHelper->EscapeString($user->getLastName());
     //First escape the string, and then change it to hash
     $pwd = sha1($user->getPassword());
     $loginid = $dbHelper->EscapeString($user->getLogin());
     $email = $dbHelper->EscapeString($user->getEmail());
     $dob = $dbHelper->EscapeString($user->getDOB());
     $language = $dbHelper->EscapeString($user->getUserLanguage());
     $usertype = $dbHelper->EscapeString($user->getUserType());
     $regdate = $dbHelper->EscapeString($user->getRegistrationDate());
     $location = $dbHelper->EscapeString($user->getLocation());
     //Null for now, because we do not need it..
     $mediaid = null;
     //$dbHelper->EscapeString($user->getMediaId();
     $ratingid = null;
     //$dbHelper->EscapeString($user->getUserRatingId());
     $emailsub = null;
     //$dbHelper->EscapeString($user->getEmailSub());
     $query_insert = "INSERT INTO " . USER . " VALUES('', '{$fname}', '{$lname}','{$loginid}','{$pwd}','{$ratingid}','{$mediaid}','{$email}','{$dob}','{$location}','{$regdate}','{$usertype}','{$language}','{$emailsub}')";
     $result = $dbHelper->executeInsertQuery($query_insert);
     //$last_inserted_id = mysql_insert_id();
     return $result;
     //which will return the last inserted id
 }
コード例 #2
0
 public function addReport($report)
 {
     $id = $report->getId();
     $reason = $report->getReason();
     $entity_for_report = $report->getEntityForReport();
     $entity_id = $report->getEntityId();
     $reported_by = $report->getReportedBy();
     $query_insert = "INSERT INTO " . REPORT . " (rep_reason, rep_entity_for_report, rep_entity_id, rep_reported_by, rep_reported_on) \n                     VALUES ('" . $reason . "', '" . $entity_for_report . "', '" . $entity_id . "', '" . $reported_by . "', NOW())";
     $dbHelper = new DBHelper();
     $last_inserted_id = $dbHelper->executeInsertQuery($query_insert);
     return $last_inserted_id;
 }
コード例 #3
0
 public function addRating($rating)
 {
     $id = $rating->getId();
     $entity_id = $rating->getEntityId();
     $like_user_id = $rating->getLikeUserId();
     $dislike_user_id = $rating->getDislikeUserId();
     //echo "RatingDataAccessor->addRating dislike_user_id: ".$dislike_user_id;
     $query_insert = "INSERT INTO " . RATING . " (rat_entity_id, rat_like_user_id, rat_dislike_user_id, rat_created_on)\n                     VALUES ('" . $entity_id . "', '" . $like_user_id . "', '" . $dislike_user_id . "', NOW())";
     //echo "RatingDataAccessor->addRating insert query: ".$query_insert."\n";
     $dbHelper = new DBHelper();
     $last_inserted_id = $dbHelper->executeInsertQuery($query_insert);
     return $last_inserted_id;
 }
コード例 #4
0
 public function AddProficient($ProfData)
 {
     $dbHelper = new DBHelper();
     //All the data members are being passed through the escape string function
     $userid = $dbHelper->EscapeString($ProfData->getUserId());
     $langid = $dbHelper->EscapeString($ProfData->getLanguageId());
     $prof = $dbHelper->EscapeString($ProfData->getProf());
     $query_insert = "INSERT INTO " . LANGUAGE_PROF . " VALUES('', '{$userid}', '{$langid}','{$prof}')";
     //echo $query_insert;
     $result = $dbHelper->executeInsertQuery($query_insert);
     //returns the last row inserted..
     return $result;
 }
コード例 #5
0
 public function addTreq($treq)
 {
     $creator_id = $treq->getTreqCreatorId();
     $entry_id = $treq->getTreqEntryId();
     $lang_id = $treq->getTreqLang();
     $date = $treq->getTreqDate();
     $insert_query = 'INSERT INTO  
                   ' . TRANS_REQUEST . ' (
                     treq_creator_id,
                     treq_entry_id,
                     treq_target_lang_id,
                     treq_date
                   )
                 VALUES (' . $creator_id . ',' . $entry_id . ',' . $lang_id . ',"' . $date . '");';
     //echo "<br>trda::addTreq() insert_query:<br>" . $insert_query;
     $dbHelper = new DBHelper();
     $last_inserted_id = $dbHelper->executeInsertQuery($insert_query);
     return $last_inserted_id;
 }
コード例 #6
0
 public function addComment($comment)
 {
     //$id = $comment->getId();
     $text = $comment->getText();
     $rating_id = $comment->getRatingId();
     $created_by = $comment->getCreatedBy();
     $entry_id = $comment->getEntryId();
     $rating_id = isset($rating_id) ? $rating_id : "";
     //printf ("CommentDataAccess text: ". $text."<br/>");
     //printf ("CommentDataAccess rating_id: ". $rating_id."<br/>");
     //printf ("CommentDataAccess created_by: ". $created_by."<br/>");
     //printf ("CommentDataAccess entry_id: ". $entry_id."<br/>");
     if ($rating_id != "") {
         $query_insert = "INSERT INTO " . COMMENT . " (com_text, com_rating_id, com_created_by, com_entry_id, com_created_on) \n                        VALUES ('" . $text . "', " . $rating_id . ", " . $created_by . ", '" . $entry_id . "', NOW())";
     } else {
         $query_insert = "INSERT INTO " . COMMENT . " (com_text, com_created_by, com_entry_id, com_created_on) \n                        VALUES ('" . $text . "', " . $created_by . ", '" . $entry_id . "', NOW())";
     }
     $dbHelper = new DBHelper();
     $last_inserted_id = $dbHelper->executeInsertQuery($query_insert);
     //printf ("CommentDataAccess mysqli_insert_id: ". $last_inserted_id);
     return $last_inserted_id;
 }
コード例 #7
0
ファイル: EntryDataAccessor.php プロジェクト: lilyfan/Tarboz
 /**
  *
  * @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;
 }
コード例 #8
0
 public function addLocation($location)
 {
     $countryname = $location->getCountryName();
     $provincename = $location->getProvinceName();
     $cityname = $location->getCityName();
     $countrycode = $location->getCountryCode();
     $query_insert = "INSERT INTO " . COUNTRY . " VALUES('', '" . $countryname . "','" . $countrycode . "')";
     $dbHelper = new DBHelper();
     $result_country = $dbHelper->executeInsertQuery($query_insert);
     if ($result_country) {
         echo "Data Inserted";
     }
     $country_id = $result_country;
     //INSERTING DATA INTO THE PROVINCE TABLE
     $query_insert = "INSERT INTO " . PROVINCE . " VALUES('', '" . $provincename . "','" . $country_id . "')";
     $dbHelper = new DBHelper();
     $result_province = $dbHelper->executeInsertQuery($query_insert);
     $province_id = $result_province;
     //INSERTING DATA INTO THE CITY TABLE
     $query_insert = "INSERT INTO " . CITY . " VALUES('', '" . $cityname . "','" . $province_id . "')";
     $dbHelper = new DBHelper();
     $result_city = $dbHelper->executeInsertQuery($query_insert);
     $city_id = $result_city;
     //returns the city id
     return $city_id;
 }