I need a function to return an array as an associate or object, with one input. Here's the code.
function fetch_article($key) {
global $sysconfig;
if ($sysconfig['datastore'] == 'wincache') {
$data = wincache_ucache_get($key);
return $data;
}elseif ($sysconfig['datastore'] == 'apc'){
$data = apc_fetch($key);
return $data;
}elseif ($sysconfig['datastore'] == ''){
$data = $db->query("SELECT * FROM pages_content WHERE id = '" . $key . "'");
$data = $data->fetch_assoc();
return $data;
}
}
I do开发者_开发知识库n't have that much experience working with functions, so please do bear with me.
It's no problem to just return the variable holding the array object.
精彩评论