/** * Get the current database connection * * @return rcube_db Database object */ public function get_dbh() { if (!$this->db) { $this->db = rcube_db::factory($this->config->get('db_dsnw'), $this->config->get('db_dsnr'), $this->config->get('db_persistent')); $this->db->set_debug((bool) $this->config->get('sql_debug')); } return $this->db; }
/** * Get the current database connection * * @return rcube_db Database object */ public function get_dbh() { if (!$this->db) { $config_all = $this->config->all(); $this->db = rcube_db::factory($config_all['db_dsnw'], $config_all['db_dsnr'], $config_all['db_persistent']); $this->db->set_debug((bool) $config_all['sql_debug']); } return $this->db; }
function hmail_db_connect() { $rcmail = rcube::get_instance(); if ($dsn = $rcmail->config->get('companyaddressbook_db_dsnw')) { $db = new rcube_db($dsn, '', FALSE); $db->set_debug((bool) $rcmail->config->get('sql_debug')); $db->db_connect('w'); $sql = 'SELECT * FROM hm_dbversion LIMIT 1'; $result = $db->query($sql); if ($db->error) { return false; } $v = $db->fetch_assoc($result); if ($v['value'] >= HMAIL_DB_VERSION_MIN && $v['value'] <= HMAIL_DB_VERSION_MAX) { return $db; } else { return false; } } else { return false; } }