저는 일종의 비디오 아카이브 인 wfsu.org/dimensions에서 일하고 있습니다. mysql과 PHP를 사용하여 관련 비디오에 대한 좋은 쿼리/알고리즘 조합을 제안하려고합니다. 데이터베이스에는 제목, 키워드, 설명, 카테고리 및 생산자를위한 또 다른 정규화 된 1 : m 테이블이 있습니다. 나는 간단한 알고리즘을 가지고 있지만 어떤 재치가있는 사람이라면 누구든지 '관련있는'비디오가 매우 부족하다는 것을 알게 될 것이다. 모든 아이디어 나 도움을 주시면 감사하겠습니다 !! 나는 비슷한 곤경에있어 사람이, 빵 부스러기를 수 있도록 내 질문에 대답하는거야Related Videos with mysql and php
//if the segment isnt a generic dimensions use this query that makes sure they're in the same category
if($segType != 2)
{
$query = "SELECT `title`, `description`, `air_date`, `keywords`, `post_id`, `img_filename`
FROM `archive_post`
WHERE `segment_type` = $segType
AND `post_id` != $id
AND NOW() > ADDTIME(`air_date`, '20:0:0')
ORDER BY `air_date` DESC LIMIT 5";
}
else //otherwise we want a query that checks to see if there are any similar keywords
{
$query = "SELECT `title`, `description`, `air_date`, `keywords`, `post_id`, `img_filename`
FROM `archive_post`
WHERE (";
$kwArray = preg_split("/[\s,-]+/", mysql_real_escape_string($keywords));
foreach($kwArray as $kw)
{
$query .= "`keywords` LIKE '%$kw%' OR";
}
$query = substr($query, 0, -3);
$query .= ")
AND `post_id` != $id
AND NOW() > ADDTIME(`air_date`, '20:0:0')
ORDER BY `air_date` DESC LIMIT 5";
}
$result = $dbConnection->runQuery($query);
if(mysql_num_rows($result) == 0) //if we can't find any 'related' videos what do?
{
}
else
{
while($row = mysql_fetch_array($result))
{
$moreTitle = $row['title'];
$moreID = $row['post_id'];
$moreDescription = cleanDescription($row['description']);
$moreDescription = substr($moreDescription, 0, 50).'...';
$moreDate = strtotime($row['air_date'], time());
$moreDate = date("F j, Y" , $moreDate);
$relatedVideos .= "<li> <a href='viewvideo.php?num=$moreID'></a><h3>$moreTitle</h3>
<div class='featuredStory'><span class='featuredDate'>$moreDate</span> ⋅ $moreDescription</div></li>";
}
}
지금까지 어떤 코드가 있습니까? 너 뭐 해봤 니? – tadman
나는 더 일반적인 개념이나 아이디어를 찾고 있었지만, 내가하고있는 것을 얻을 수 있도록 돕기 위해 몇 가지 코드를 넣었다. –
http://stackoverflow.com/questions/2323768/how-does-the-amazon-recommendation-feature-work의 맨 위로 대답에서 다룬 개념을 살펴보십시오. 이것은 당신이 볼 수있는 개념입니다. – jdphenix