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

(12-13-2016, 03:49 PM)dsv Wrote:
(12-13-2016, 02:30 AM)grego Wrote:
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.        
   }


You don't need to assign the DB class, it's asigned by default.

PHP Code:
$this->load->database('default');
var_dump($this->db); 

https://codeigniter.com/user_guide/datab...cting.html


Hello,
Thank you for your reply. I have to add this because in my database configuration file I use different databases and for each database I use different settings. In model I use sometimes $this->db, another time $this->db2 to get data from different database.
But this is not important for this issue because it is not working.
I put your code, here is result:


Code:
object(CI_DB_pdo_sqlsrv_driver)#16 (74) {
 ["subdriver"]=>
 string(6) "sqlsrv"
 ["_random_keyword":protected]=>
 array(2) {
   [0]=>
   string(7) "NEWID()"
   [1]=>
   string(8) "RAND(%d)"
 }
 ["_quoted_identifier":protected]=>
 bool(true)
 ["dbdriver"]=>
 string(3) "pdo"
 ["options"]=>
 array(2) {
   [65001]=>
   int(1)
   [12]=>
   int(1)
 }
 ["return_delete_sql":protected]=>
 bool(false)
 ["reset_delete_data":protected]=>
 bool(false)
 ["qb_select":protected]=>
 array(0) {
 }
 ["qb_distinct":protected]=>
 bool(false)
 ["qb_from":protected]=>
 array(0) {
 }
 ["qb_join":protected]=>
 array(0) {
 }
 ["qb_where":protected]=>
 array(0) {
 }
 ["qb_groupby":protected]=>
 array(0) {
 }
 ["qb_having":protected]=>
 array(0) {
 }
 ["qb_keys":protected]=>
 array(0) {
 }
 ["qb_limit":protected]=>
 bool(false)
 ["qb_offset":protected]=>
 bool(false)
 ["qb_orderby":protected]=>
 array(0) {
 }
 ["qb_set":protected]=>
 array(0) {
 }
 ["qb_aliased_tables":protected]=>
 array(0) {
 }
 ["qb_where_group_started":protected]=>
 bool(false)
 ["qb_where_group_count":protected]=>
 int(0)
 ["qb_caching":protected]=>
 bool(false)
 ["qb_cache_exists":protected]=>
 array(0) {
 }
 ["qb_cache_select":protected]=>
 array(0) {
 }
 ["qb_cache_from":protected]=>
 array(0) {
 }
 ["qb_cache_join":protected]=>
 array(0) {
 }
 ["qb_cache_where":protected]=>
 array(0) {
 }
 ["qb_cache_groupby":protected]=>
 array(0) {
 }
 ["qb_cache_having":protected]=>
 array(0) {
 }
 ["qb_cache_orderby":protected]=>
 array(0) {
 }
 ["qb_cache_set":protected]=>
 array(0) {
 }
 ["qb_no_escape":protected]=>
 array(0) {
 }
 ["qb_cache_no_escape":protected]=>
 array(0) {
 }
 ["dsn"]=>
 string(24) "sqlsrv:server=10.160.X.X"
 ["username"]=>
 string(2) "myUser"
 ["password"]=>
 string(11) "myPassword"
 ["hostname"]=>
 NULL
 ["database"]=>
 string(9) "myDatabase"
 ["dbprefix"]=>
 string(0) ""
 ["char_set"]=>
 string(4) "utf8"
 ["dbcollat"]=>
 string(15) "utf8_general_ci"
 ["encrypt"]=>
 bool(false)
 ["swap_pre"]=>
 string(0) ""
 ["port"]=>
 string(0) ""
 ["pconnect"]=>
 bool(true)
 ["conn_id"]=>
 object(PDO)#15 (0) {
 }
 ["result_id"]=>
 object(PDOStatement)#17 (1) {
   ["queryString"]=>
   string(70) "SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi"
 }
 ["db_debug"]=>
 bool(true)
 ["benchmark"]=>
 float(0.0012590885162354)
 ["query_count"]=>
 int(1)
 ["bind_marker"]=>
 string(1) "?"
 ["save_queries"]=>
 bool(true)
 ["queries"]=>
 array(1) {
   [0]=>
   string(70) "SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi"
 }
 ["query_times"]=>
 array(1) {
   [0]=>
   float(0.0012590885162354)
 }
 ["data_cache"]=>
 array(0) {
 }
 ["trans_enabled"]=>
 bool(true)
 ["trans_strict"]=>
 bool(true)
 ["_trans_depth":protected]=>
 int(0)
 ["_trans_status":protected]=>
 bool(true)
 ["_trans_failure":protected]=>
 bool(false)
 ["cache_on"]=>
 bool(false)
 ["cachedir"]=>
 string(0) ""
 ["cache_autodel"]=>
 bool(false)
 ["CACHE"]=>
 NULL
 ["_protect_identifiers":protected]=>
 bool(true)
 ["_reserved_identifiers":protected]=>
 array(1) {
   [0]=>
   string(1) "*"
 }
 ["_escape_char":protected]=>
 string(1) """
 ["_like_escape_str":protected]=>
 string(13) " ESCAPE '%s' "
 ["_like_escape_chr":protected]=>
 string(1) "!"
 ["_count_string":protected]=>
 string(19) "SELECT COUNT(*) AS "
 ["compress"]=>
 bool(false)
 ["stricton"]=>
 bool(false)
 ["failover"]=>
 array(0) {
 }
}

Any idea?
Best regards,
Grzegorz
Best regards,
Grzegorz
Reply


Messages In This Thread
RE: Database name problem - not possible choice dbname - by grego - 12-14-2016, 12:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB