Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: jamil_isayyed on October 22, 2012, 07:59:21 AM

Title: defining and using two databases.
Post by: jamil_isayyed on October 22, 2012, 07:59:21 AM
Hello,

i want to define another database than roundcube, and i want to allow the roundcube to use it, add data to it. can i define the database in db.inc.php.dist, if yes should i define a new array "$rcmail_config = array();" or use it and add the data to it such as the connection.

and for instance define a function get_dbh() in rcube.php that take the values that i have defined it in the database.

public function get_dbh()
166 {
167 if (!$this->db) {
168 $config_all = $this->config->all();
169
170 $this->db = new rcube_mdb2($config_alldb_dsnw?, $config_alldb_dsnr?, $config_alldb_persistent?);
171 $this->db->sqlite_initials = INSTALL_PATH . 'SQL/sqlite.initial.sql';
172 $this->db->set_debug((bool)$config_allsql_debug?);
173 }
174
175 return $this->db;
176 }

and for example then use it to add the last login of the user in other database as in rcube_user.php

/ 367 * Update user's last_login timestamp
368 */
369 function touch()
370 {
371 if ($this->ID) {
372 $this->db->query(
373 "UPDATE ".$this->db->table_name('users').
374 " SET last_login = ".$this->db->now().
375 " WHERE user_id = ?",
376 $this->ID);
377 }
378 }

i am wondering is that possible or not? Sorry for annoying and Thanks a lot.
Title: Re: defining and using two databases.
Post by: alec on October 22, 2012, 09:45:32 AM
Just create another instance of db object. Sql driver of password plugin does this. See plugins/password/drivers/sql.php.