php - Memcache & Mysqli prepared statement problem -
check code below, have following problem: last 2 parameters dynamic in sql statement, how can make memcache gets right parameters , not ? ?, shows me only? adding second variable $sql1 = "select id title vtext tpost order id desc limit $var1, $var2"; ? or gives better solution?
$sql = "select id, title, vtext tpost order id desc limit ?, ?"; $content = $memcache->get($sql); if($content == null) { $stmt = $mysqli->prepare($sql); $stmt->bind_param('ii', $offset, $rowsperpage); $stmt->execute(); $stmt->bind_result($r_id, $r_title, $r_vtext); while ($stmt->fetch()) { $data[] = array( 'id' => $r_id, 'title' => $r_title, 'vtext' => $r_vtext); } $stmt->close(); $memcache->set($sql,$data,0,$cache_time); } thank help
$sql = "select id, title, vtext tpost order id desc limit ?, ?"; $key = "select id, title, vtext tpost order id desc limit $r_title, $r_vtext"; $content = $memcache->get($sql); if($content == null) { $stmt = $mysqli->prepare($sql); $stmt->bind_param('ii', $offset, $rowsperpage); $stmt->execute(); $stmt->bind_result($r_id, $r_title, $r_vtext); while ($stmt->fetch()) { $data[] = array( 'id' => $r_id, 'title' => $r_title, 'vtext' => $r_vtext); } $stmt->close(); $memcache->set($key,$data,0,$cache_time); }
Comments
Post a Comment