function db_query_mysql($sql, &$res, $timeout = 0, $type = '0', $key = null)
{
#echo "MC:".($type)."#<br>";
global $dbhost, $dbuser, $dbpassword, $dbname;
$db = new db_Mysql();
$db->init_con($dbhost, $dbuser, $dbpassword, $dbname);
$db->create_con();
$result = $db->query($sql);
if ($result == false) {
$db->free();
$db->close();
return false;
} else {
$res = array();
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$res[] = $row;
}
global $memcached_host;
$options = array('servers' => array($memcached_host), 'debug' => false, 'compress_threshold' => 510240, 'persistant' => false);
$mc = new memcached($options);
if ($type == "1") {
//add type
$mc->add($key, $res, $timeout);
}
if ($type == "2") {
//replace
$mc->replace($key, $res, $timeout);
}
$mc->disconnect_all();
}
$db->free();
$db->close();
return true;
}