这是我在index.php文件中的主要查询
我试图用phpfastcache快速缓存缓存这个查询。
$shorting = $conn->prepare("SELECT text,time FROM small WHERE active='0' ORDER BY time DESC LIMIT 10");
$shorting->execute();
while($obj = $shorting->fetch(PDO::FETCH_OBJ)){
<div id="lastnews_title">
<div><?php echo $obj->text; ?></div>
<div style="text-align:left">
<?php echo timeTonow($obj->time); ?>
</div>这是phpfastcache站点中的一个示例。
// Require Library
require_once("../phpfastcache/phpfastcache.php");
// simple Caching with:
$cache = phpFastCache();
// Try to get $products from Caching First
// product_page is "identity keyword";
$products = $cache->get("product_page");
if($products == null) {
$products = "DB QUERIES | FUNCTION_GET_PRODUCTS | ARRAY | STRING | OBJECTS";
// Write products to Cache in 10 minutes with same keyword
$cache->set("product_page",$products , 600);
}
// use your products here or return it;
echo $products;我用我的require_once("../phpfastcache/phpfastcache.php");写index.php
我不知道如何在这个缓存类中插入我的查询?
抱歉英语不太好
发布于 2014-03-04 14:34:42
您没有围绕这组php语句的一组<php>标记
$shorting = $conn->prepare("SELECT text,time FROM small WHERE active='0' ORDER BY time DESC LIMIT 10");
$shorting->execute();
while($obj = $shorting->fetch(PDO::FETCH_OBJ)){这段代码看上去不像它的功能,我想这就是你要讲的重点。
您应该学习PHP的一些基础知识。我对PHP和您想做的事情知之甚少,但我知道这是糟糕的"php“语法。
第一个代码块应该是这样的:
$shorting = $conn->prepare("SELECT text,time FROM small WHERE active='0' ORDER BY time DESC LIMIT 10");
$shorting->execute();
while($obj = $shorting->fetch(PDO::FETCH_OBJ)){
echo "<div id='lastnews_title'>";
echo "<div> $obj->text </div>";
echo "<div style='text-align:left'>";
echo timeTonow($obj->time);
echo "</div>"
}您缺少了一个结束的div标记
我省略了php标记,因为我假设这是php文档,所有这些都包含在一组已经是<php> </php>的php标记中。
https://stackoverflow.com/questions/22116573
复制相似问题