2017-04-02 59 views
0

我有这样的代码从我的源Memcached的结果= 0

if ($where != "") 
     $where = "WHERE $where"; 

$res = $mysqli->query("SELECT COUNT(id) FROM torrents $where LIMIT 1") or die(mysql_error()); 
$row = mysqli_fetch_array($res); 
$count = $row[0]; 

我尝试这是该corect? :

if ($where != "") 

     $where = "WHERE $where"; 
    $ress = $mysqli->query('SELECT COUNT(id) FROM torrents $where LIMIT 1';) or die(mysql_error()); 
$nombre ='details'.$ress; 
$res = mysqli_query($ress); 
$count = array(); 
while($count = mysqli_fetch_array($res)) $rows[] = $count; 
$memcache->set($nombre, $count, 1); 

结果 “对不起朋友找不到”

+0

所以..还有就是在你的表中没有数据 – Ravi

回答

0
if ($where != "") 
     $where = "WHERE $where"; 
    $res = mysql_query("SELECT COUNT(id) FROM torrents $where LIMIT 100") or die(mysql_error()); 
$key = md5($res); 
$get_data = $memcache->get($key); 

if($get_data) { 
echo 'Data Pulled From Cache'; 
} else { 
    while ($row = mysql_fetch_array($res)) { 
     $memcache->set($key, $res, TRUE, 3600); 
     $count = $row[0]; 
} 
} 

虽然解决了我的prolem