Welcome Guest, Not a member yet? Register   Sign In
Database name problem - not possible choice dbname
#1

Hello All,
I have a big issue with database settings.
it's my setting below:

PHP Code:
$db['default'] = array(
        'dsn'   => '',
        'hostname' => 'sqlsrv:server=xxx.xxx.xxx.xxx',
        'username' => 'username',
        'password' => 'my_pass',
        'database' => 'MyDatabase',
        'dbdriver' => 'pdo',
        'dbprefix' => '',
        'pconnect' => TRUE,
        'db_debug' => TRUE,
        'cache_on' => FALSE,
        'cachedir' => '',
        'char_set' => 'utf8',
        'dbcollat' => 'utf8_general_ci',
        'swap_pre' => '',
        'encrypt' => FALSE,
        'compress' => FALSE,
        'stricton' => FALSE,
        'failover' => array()
); 



My mssql_model.php file contains:


PHP Code:
class Mssql_model extends CI_Model
{
    
    
function __construct()
    {
        parent::__construct();
        $this->db             $this->load->database('default'TRUE); // Load the db, and assign to the member var.        
   }


    public function getTest() {
    
        $q 
"SELECT top 2 * FROM MyTable";
        
        $query 
$this->db->query($q);
        
            if
($query->num_rows() > 0)    {
                
                $row         
$query->result_array();
                
                return $row
;
            } else     return array();;
    }
    
    
    
    public 
function getInfo() {
    
        $q 
"SELECT @@servername, DB_NAME() as dbname";
        
        $query 
$this->db->query($q);
        
            if
($query->num_rows() > 0)    {
                
                $row         
$query->result_array();
                
                return $row
;
            } else     return array();;
    }    
    



When I call getInfo result is like this:


PHP Code:
Array
(
   [0] => Array
       (
           [] => MyServerName
           
[dbname] => master
       
)




When I call getTest() it's not working.
It's looks like driver can't use parameter database. How to fix it or maybe I am wrong in my code?
Before I used a mssql driver not pdo but now I have to change a server and mssql driver is not supported anymore.

Thank you for your suggestions.
Best regards,
Grzegorz
Best regards,
Grzegorz
Reply


Messages In This Thread
Database name problem - not possible choice dbname - by grego - 12-13-2016, 02:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB