예제 #1
0
 public function create($title, $description, $location, $eventID)
 {
     /**@todo this is unsafe**/
     $con = get_mysql_connection();
     $img = new Image();
     $img->data['TITLE'] = $title;
     $img->data['DESCRIPTION'] = $description;
     $img->data['LOCATION'] = $location;
     $img->data['EVENTID'] = $eventID;
     $img_result = $img->save();
     if (!$img_result) {
         return false;
     } else {
         return $img->id;
     }
 }
예제 #2
0
            $where .= "saat.LabelID in (" . implode(",", $topicFilter[$i]->labelIDs) . ") ";
        }
        $where .= ") ";
        if (strlen($having) > 0) {
            $having .= ' and ';
        }
        $having .= " count(distinct al.AttributeID)=" . sizeof($topicFilter) . " ";
    }
    if (strlen($having) > 0) {
        $having = 'having ' . $having;
    }
    $orderByInner = $fetchOngoingStories ? "TopUserCountRecent desc, WeightedSizeRecent desc" : "TopUserCount desc, StartTime desc";
    //$orderByOuter = ($fetchOngoingStories ? "" : "order by StartTime desc");
    $orderByOuter = "order by StartTime desc";
    $sql = "select * from (\n        select\n          Story.StoryID,\n          UserCount,\n          round(WeightedSize) WeightedSize,\n          StartTime,\n          Title\n        from Story {$join}\n        where not IsHidden {$where}\n        group by Story.StoryID\n        {$having}\n        order by {$orderByInner}\n        limit 20) T\n      {$orderByOuter}";
    $conn = get_mysql_connection();
    $conn->query("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
    $result = $conn->query($sql);
    $conn->query("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ");
    $stories = array();
    while ($row = $result->fetch_object()) {
        $story = array();
        $story["story_id"] = $row->StoryID;
        $story["user_count"] = $row->UserCount;
        $story["weighted_size"] = $row->WeightedSize;
        //    $story["start_time"] = date_format(date_create($row->StartTime), 'Y-m-d\TH:i:s\Z');
        $story["start_time"] = $row->StartTime;
        $story["title"] = $row->Title;
        $stories[] = $story;
    }
} catch (Exception $e) {
예제 #3
0
 public static function fbEventExists($evId)
 {
     $con = get_mysql_connection();
     $sql = "SELECT * FROM Events WHERE FacebookId = '" . mysql_escape_string($evId) . "' OR FacebookEventId = '" . mysql_escape_string($evId) . "'";
     $con->query("SET NAMES utf8");
     $result = $con->query($sql);
     $con->close();
     if ($result && mysqli_num_rows($result) > 0) {
         return true;
     } else {
         return false;
     }
 }
예제 #4
0
 function prepared_save()
 {
     $con = get_mysql_connection('prepared');
     $columns = '';
     $question = '';
     foreach ($this->keymap as $k => $v) {
         if ($v == 'ID') {
             continue;
         }
         $columns .= "{$v},";
         if (strpos($v, 'LngLat') !== false) {
             $question .= "GeomFromText(?),";
         } else {
             $question .= "?,";
         }
     }
     $columns = rtrim($columns, ",");
     $question = rtrim($question, ",");
     $stmt_names = $con->prepare('SET NAMES utf8');
     $stmt = $con->prepare(sprintf("INSERT INTO %s (%s) VALUES (%s)", $this->tablename, $columns, $question));
     $params = array_values($this->data);
     $param_type = '';
     foreach ($this->data as $dt) {
         $param_type .= 's';
     }
     $a_params[] =& $param_type;
     for ($i = 0; $i < count($params); $i++) {
         $a_params[] =& $params[$i];
     }
     call_user_func_array(array(&$stmt, 'bind_param'), $a_params);
     $stmt_names->execute();
     $result = $stmt->execute();
     $this->id = $stmt->insert_id;
     return $result;
 }
예제 #5
0
파일: dbconn.php 프로젝트: echo0101/eScan
function query_to_array($query, $conToUse = null)
{
    $con = $conToUse;
    if ($con == null) {
        $con = get_mysql_connection();
    }
    $result = mysql_query($query, $con) or die('mysql_query: ' . mysql_error());
    if ($conToUse == null) {
        mysql_close($con);
    }
    $rows = array();
    while (($row = mysql_fetch_array($result)) != null) {
        $rows[] = $row;
    }
    return $rows;
}