我做了這個功能,因爲我在整個網站上使用它,我想知道它是否是一種優化它的方法,使它運行更快?我也想知道我是否認爲功能好?謝謝。有沒有辦法優化這個定製功能?
// function to get the seo friendly url of a video based on it's id
function video_seo_urls($video_id)
{
global $site_url;
$sql = dbquery('SELECT `post_name`, `new_post_name`, `category` FROM `videos` WHERE `id` ="'.$video_id.'" LIMIT 0,1;');
while($row = mysql_fetch_array($sql))
{
$post_name = $row["post_name"];
$new_post_name = $row["new_post_name"];
$category_id = $row["category"];
}
$csql = dbquery('SELECT `category_slug` FROM `categories` WHERE `category_id` = "'.$category_id.'" LIMIT 0,1;');
while($row = mysql_fetch_array($csql))
{
$category = $row["category_slug"];
}
if ($new_post_name !== "")
{
$video_slug = $new_post_name;
}
else if ($new_post_name == "" && $post_name !== "")
{
$video_slug = $post_name;
}
$video_url = $site_url.'video/'.$category.'/'.$video_slug.'/';
return $video_url;
}
echo video_seo_urls(14775);
它真的太慢了,你必須優化? – JJJ 2012-02-03 17:10:41
聖牛 - 你真的寫這樣的無格式代碼嗎?如果您希望人們幫助您改進它,請格式化並發表評論。 – 2012-02-03 17:11:05
對不起,它是通過手機發布的 – m3tsys 2012-02-03 17:14:53