this is my main query in index.php file
I am trying to cache this query with 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>
this is an example in phpfastcache site
// 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;
I write require_once("../phpfastcache/phpfastcache.php");
in my index.php
I dont know how to insert my query in this cache class?
sorry for bad english
you don't have a set of <php>
tags surrounding this set of php statements
$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)){
this code doesn't look like it functions, and I think that is the point you are getting at here.
you should study some of the basics of PHP. I know very Little about PHP and what you are trying to do, but I know that this is bad "php" grammar.
this is what your first code block should look like:
$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>"
}
you are missing an ending div
tag
I left out the php tags because I assume that this is a php document and that all of this is enclosed in a set of php tags already <php> </php>