[eluser]Unknown[/eluser]
Background: I am trying to move my Language files into a DB structure so I can easily build
an interface for my client to change the copy without having to directly modify Language files (think CMS).
I use memcached cache support on my DB Layer
The issue I have is that when I instantiating a CI object using the get_instance() function in the language file then use it to call my query I get a "Fatal error: Call to a member function is_supported() on a non-object". It seems the Cache Library has not been loaded.
Anyone know if I can load the cache library manually?
Any other suggestions?
Here is the code I think is relevant.
common_lang.php (autoloaded)
Code:
<?php
$ci =& get_instance();
$ci->load->model('SystemModel');
$ci->load->config();
$values = $ci->SystemModel->getLangValues($ci->config->item('language'));
foreach ($values as $pair){
$lang[$pair['field']] = $pair['copy'];
}
systemmodal.php
Code:
public function getLangValues($lang){
$sql = <<<SQL
SELECT
language_fields.field as field,
language_fields.category as category,
language_field_copy.copy as copy
FROM
language_fields,
language_field_copy
WHERE
language_field_copy.field_id = language_fields.id
AND
language_field_copy.language = ?
SQL;
$this->cacheArray['function'] = 'LangueValues';
$this->cacheArray['id'] = 'all';
return $this->query($sql,array($lang),$this->cacheArray);
}
My_Model (adds caching support)
Code:
public function query($sql, $binds=false, $cacheArray = null, $returnObject=true) {
log_message('debug', 'My Model Query Called:');
$timeOut = (!empty($cacheArray['cacheTime']))?$cacheArray['cacheTime']:$this->config->item('cacheTimeOut');
// Hook into Memcache here?
// I want to explicitly Clear cache so looking for the false case not empty value
if((empty($cacheArray))|| (!$this->CI->cache->memcached->is_supported()) ){
log_message('debug', 'Cache not attempted: ' . $cacheArray['group'] .':'.$cacheArray['function'].':'. $cacheArray['id']);
if($returnObject === true){
$result = $this->DB->query($sql, $binds);
if(is_object($result)) {
return $result->result_array();
} else {
return true;
}
} else {
return $this->DB->query($sql, $binds);
}
} else {
if((!empty($cacheArray['clear'])) && ($cacheArray['clear'] === TRUE)) {
$return = $this->DB->query( $sql, $binds);
$this->extendedquerylib->deleteCache($cacheArray);
} else {
if (!$return = $this->extendedquerylib->getCache($cacheArray)) {
if ($result = $this->DB->query($sql, $binds)) {
$return = $result->result_array();
$this->extendedquerylib->addCache($cacheArray, $return, $timeOut);
}else {
$return = false;
}
}
}
return $return;
}
}
I appreciate any help!!