Ejemplo n.º 1
0
 public function testInstantiation()
 {
     $exception = new Gone(9, [1, 2, 3]);
     $this->assertEquals('Gone', $exception->getMessage());
     $this->assertEquals(410, $exception->getStatusCode());
     $this->assertEquals(9, $exception->getCode());
     $this->assertEquals([1, 2, 3], $exception->getDetails());
 }
Ejemplo n.º 2
0
            $sql = "SELECT want_number FROM ft_view WHERE view_id = :view_id";
            $stmt = $this->db->prepare($sql);
            $stmt->execute(array(':view_id' => $get_data['spotId']));
            $stmt->setFetchMode(PDO::FETCH_ASSOC);
            $current_number = $stmt->fetch();
            $new_number = $current_number['want_number'] + 1;
            $sql_update = "UPDATE ft_view SET want_number = :want_number WHERE view_id = :view_id";
            $stmt_update = $this->db->prepare($sql_update);
            $stmt_update->bindValue(':want_number', $new_number);
            $stmt_update->bindValue(':view_id', $get_data['spotId']);
            $res = $stmt_update->execute();
            if ($res) {
                $this->res['code'] = 0;
                $this->res['message'] = 'success';
            } else {
                $this->res['code'] = 1037;
                $this->res['message'] = '更新数据库失败';
            }
        } elseif ($get_data['type'] == 2) {
        } else {
            $this->res['code'] = 1036;
            $this->res['message'] = '结果为空';
        }
    }
    function __destruct()
    {
        $this->die_json($this->res);
    }
}
$obj = new Gone();
$obj->index();