Esempio n. 1
0
<?php

header("Content-type: text/html; charset=utf-8");
header('Access-Control-Allow-Origin:*');
require_once 'function.php';
$user = new User();
$track = new Track();
// 所有p开头意为param
$pHash = @I('uhash');
$uid = $user->GetUserId($pHash);
if ($uid == null) {
    $user->AddUser($pHash);
}
$res_json = array('status' => false);
// 分发
switch (@I('type')) {
    // 增加追踪
    case 'addtrack':
        $pQuestionid = @I('qid');
        $pAnswerid = @I('aid');
        if ($pAnswerid == null || $pQuestionid == null) {
            $res_json['info'] = 'Aid or Qid 未命中';
            break;
        }
        if ($track->AddTrack($uid, $pQuestionid, $pAnswerid) > 0) {
            $res_json['status'] = true;
        }
        break;
    case 'removetrack':
        $pQuestionid = @I('qid');
        $pAnswerid = @I('aid');
Esempio n. 2
0
 function GetDogsByOwner(User $user)
 {
     $dogs = [];
     $query = "\n\t\t\t\tSELECT dog.id AS dog_id, breed.id AS breed_id, litter_id, breed, name, country, city, birth, gender, about, user_id\n\t\t\t\tFROM dog\n\t\t\t\tINNER JOIN breed ON dog.breed_id = breed.id \n\t\t\t\tWHERE user_id = '" . $user->GetUserId() . "'";
     $result = $this->database->GetMysqli()->query($query);
     // Loopa för varje rad
     while ($row = $result->fetch_assoc()) {
         $dog = new Dog($this->database, $row['dog_id'], $row['litter_id']);
         $dog->breed = $row['breed'];
         $dog->breedid = $row['breed_id'];
         $dog->name = $row['name'];
         $dog->country = $row['country'];
         $dog->city = $row['city'];
         $dog->birth = $row['birth'];
         $dog->gender = $row['gender'];
         $dog->about = $row['about'];
         $dog->userid = $row['user_id'];
         // Spara ett hundobjekt i arrayen.
         $dogs[] = $dog;
     }
     return $dogs;
 }