【发布时间】:2013-08-31 17:29:05
【问题描述】:
考虑这个示例代码:
$storyID = 1;
$detailsCache = 'details'.$storyID;
if(!apc_exists($detailsCache)){
$phases_details = <<<SQL
SELECT stp.stp_id,
stp.stp_name,
stp.stp_position,
FROM story_phase stp
WHERE stp.stp_stl_id = $storyID
SQL;
$resultdetails = Helpers::execute_query($phases_details,"Get phase details failed.");
**// i cant cache the result here like apc_store($detailsCache, $phases_details);**
}
$result_phases_details = apc_fetch($detailsCache);
while($row = mysql_fetch_assoc($result_phases_details)){
// some logic
}
有没有更好的缓存结果的方法?
【问题讨论】:
-
Helpers::execute_query来自哪里? -
抱歉忽略。它是一个通用类,具有执行 mysql_query($query); 的 execute_query($query) 函数
-
是的,我很担心。您不应该在新应用程序中使用
mysql_query,其次,看起来$storyID没有正确转义。这两件事都很糟糕。 -
同意!非常感谢您的建议。 :) 关于如何以更好的方式实现缓存的任何想法?