Пример #1
0
 public function deletePhoto($userId)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $query = 'DELETE FROM photo WHERE fk_id_user=' . $userId;
     mysql_query($query) or die("Error in query: {$query}. " . mysql_error());
     mysql_close($connection);
 }
Пример #2
0
 public function deleteQueryByID($queryID)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $query = "DELETE FROM queries WHERE id={$queryID}";
     mysql_query($query) or die("Error in query: {$query}. " . mysql_error());
     mysql_close($connection);
     return $queryID;
 }
Пример #3
0
 public function getStatisticTitleById($sid)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $query = 'SELECT title FROM statistics WHERE id=' . $sid;
     $result = mysql_query($query) or die("Error in " . $query);
     $row = mysql_fetch_assoc($result);
     $title = $row['title'];
     mysql_free_result($result);
     mysql_close($connection);
     return $title;
 }
Пример #4
0
 public function loadAllComments($qId)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $result = mysql_query("SELECT * FROM comment WHERE FK_queryId='{$qId}'") or die("Error");
     //TODO DATE
     $ans = array();
     while ($row = mysql_fetch_assoc($result)) {
         $ans[$row['id']] = $row['text'];
     }
     mysql_free_result($result);
     mysql_close($connection);
     return $ans;
 }
Пример #5
0
 public function getMessage($mid)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $result = mysql_query("SELECT * FROM messages WHERE message_id = '{$mid}'");
     $message = mysql_fetch_array($result);
     $ans = array();
     $ans['title'] = $message['message_title'];
     $ans['from'] = $message['from_user'];
     $ans['content'] = $message['message_contents'];
     mysql_free_result($result);
     mysql_close($connection);
     return $ans;
 }
Пример #6
0
 /**
  *
  * @param <type> $id the user id to modify the values here
  * @param <type> $userInstanceNewValues  the new values of the user info
  *                                          that are in the user instance
  */
 public function modifyUserInfo($id, $userInstanceNewValues)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $userId = $userInstanceNewValues->getId();
     $gender = $userInstanceNewValues->gender;
     $maritalStatus = $userInstanceNewValues->maritalSt;
     $studies = $userInstanceNewValues->studies;
     $institutionName = $userInstanceNewValues->getInstitutionName();
     $country = $userInstanceNewValues->getCountry();
     $religion = $userInstanceNewValues->getReligion();
     $query = "UPDATE userinfo set gender='" . $gender . "', maritalSt='" . $maritalStatus . "', studies='" . $studies . "' , InstitutionName='" . $institutionName . "'  , currentLocation='" . $country . "' , religion='" . $religion . "'  where FK_users=" . $userId;
     mysql_query($query) or die("Error in query modifying user info : {$query}. " . mysql_error() . " and the user id is" . $id);
     mysql_close($connection);
 }
Пример #7
0
 public function selectAnswersByQueryId($qid)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $ans = array();
     $query = 'SELECT id FROM qanswer where FK_queries = ' . $qid;
     $result = mysql_query($query) or die("Error in query: {$query}. " . mysql_error());
     $ix = 0;
     while ($answer = mysql_fetch_assoc($result)) {
         $ans[$ix++] = $answer['id'];
     }
     mysql_free_result($result);
     mysql_close($connection);
     return $ans;
 }
Пример #8
0
<?php

require_once '../util.php';
require_db();
$connector = new DBConnector();
$connection = $connector->createConnection();
$name = "photo1";
$extension = "jpg";
$path = "path";
$userId = 1;
$size = 123;
$query = "INSERT INTO photo (name,extension,path,fk_id_user,size_kb) VALUE ('{$name}','{$extension}','{$path}','{$userId}', '{$size}');";
$result = mysql_query($query);
if (!$result) {
    return "error photo";
}
$userId = 12;
$query = 'DELETE FROM photo WHERE fk_id_user=' . $userId;
$result = mysql_query($query);
$rowsMysql = mysql_affected_rows();
if ($rowsMysql < 0) {
    return "error i cant delete more records";
}
if (!$result) {
    return "error photo";
}
mysql_close($connection);
class DBConnector
{
    function createConnection()
    {
Пример #9
0
 public function newTracking($follower, $followed)
 {
     $connector = new DBConnector();
     $connection = $connector->createConnection();
     $date = date('Y-m-d H:i:s');
     $query = "INSERT INTO trackings (followedId, followerId, approved, notified, date) VALUES ({$followed}, {$follower}, 0, 0, '{$date}')";
     mysql_query($query) or die("Error");
     $tid = mysql_insert_id();
     mysql_close($connection);
     return $tid;
 }
Пример #10
0
 public function initTransaction()
 {
     $connector = new DBConnector();
     $this->connection = $connector->createConnection();
 }