以下代码可以通过filmName搜索电影,但我想添加更多功能,如搜索电影的年份和演员。由于我使用的是Angular JS,因此它很难实现
我的要求是使用更高级的搜索,例如filmbyyear和Actor Name,我可以使用上面的代码集成相同的代码,例如:
按;WITH Points as(
SELECT TOP 100 Name, AddressLine1,
AddressLatitude, AddressLongitude
, geography::STGeomFromText('POINT(' + CONVERT(varchar(50),AddressLatitude) + ' ' + CONVERT(varchar(50),AddressLongitude) + ')',4326) as GeoPoint
FROM ServiceFacility
WHERE 1=1
AND AddressLatitude BETWEEN -90 AND 90
AND AddressLongitude BETWEEN -90 AND 90)
SELECT P1.*, CP.Name as DestinationName, CP.Dist
INTO #tmp_Distance
FROM Points P1
CROSS APPLY (SELECT Name, AlternateName,
geography::STGeomFromText('POINT(' + CONVERT(varchar(50),P2.AddressLatitude) + ' ' + CONVERT(varchar(50),P2.AddressLongitude) + ')',4326).STDistance(P1.GeoPoint)/1609.344 as Dist
FROM ServiceFacility as P2
WHERE 1=1
AND P1.Name <> P2.Name --Don't compare it to itself
AND P2.AddressLatitude BETWEEN -90 AND 90
AND P2.AddressLongitude BETWEEN -90 AND 90
) as CP
CREATE CLUSTERED INDEX tmpIX ON #tmp_Distance (name, Dist)
SELECT * FROM
(SELECT *, ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Dist ASC) as Rnk FROM #tmp_Distance) as tbl1
WHERE rnk = 1
DROP TABLE #tmp_Distance
filmName LIKE '%$filmName%' AND '%$filmYear%' AND '%$filmActor%'
答案 0 :(得分:0)
根据您的数据,您需要对其进行解码
{"movie":[{"film":"Besharam","param":"besharam-film-2013.html","filmYear":"2013","filmActor":"Ranbir Kapoor, Pallavi Sharda, Rishi Kapoor, Neetu Singh, Javed Jaffrey, Amitosh Nagpal, Kamal Kiri, Kunal Agrawal, Mohan Kapoor, Remo d'souza, Vishal Singh"}]}
$data = json_decode($json);
$file = $data->movie[0]->film;
$fileYear = $data->movie[0]->filmYear;