Welcome Guest, Not a member yet? Register   Sign In
session with a specific database
#1

[eluser]Mainboard[/eluser]
hey everyone, i have a question, i stated to create a little intranet and i used two database so in my database.php i have this
Code:
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "user";
$db['default']['password'] = "pass";
$db['default']['database'] = "db1";
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

$active_group = "db2";
$active_record = TRUE;

$db['db2']['hostname'] = "localhost";
$db['db2']['username'] = "user";
$db['db2']['password'] = "pass";
$db['db2']['database'] = "db2";
$db['db2']['dbdriver'] = "mssql";
$db['db2']['dbprefix'] = "";
$db['db2']['pconnect'] = FALSE;
$db['db2']['db_debug'] = TRUE;
$db['db2']['cache_on'] = FALSE;
$db['db2']['cachedir'] = "";
$db['db2']['char_set'] = "utf8";
$db['db2']['dbcollat'] = "utf8_general_ci";

and of course because i used a multiple database i don't use the library 'database' in the autoload.php because i use this
Code:
$this->default_db = $this->load->database('default', true);
for each connection that i need, but the problem is that, i want to use the session data to a database so i created another library session to redirect to my database default and works but when i logout, this message appears

A Database Error Occurred

Deletes are not allowed unless they contain a "where" or "like" clause.

Filename: C:\AppServ\www\intranet\fr@m3work_$ourc3_cod3\database\DB_active_rec.php

Line Number: 1599

and this is my function of sess_destroy
Code:
function sess_destroy()
    {
        // Kill the session DB row
        if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
        {
            
            $this->CI->load->database('default', True)->where('session_id', $this->userdata['session_id']);
            $this->CI->load->database('default', True)->delete($this->sess_table_name);
            //$this->CI->db->where('session_id', $this->userdata['session_id']);
            //$this->CI->db->delete($this->sess_table_name);
        }

        // Kill the cookie
        setcookie(
                    $this->sess_cookie_name,
                    addslashes(serialize(array())),
                    ($this->now - 31500000),
                    $this->cookie_path,
                    $this->cookie_domain,
                    0
                );
    }
any suggestion?




Theme © iAndrew 2016 - Forum software by © MyBB