• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI 3.0 + SQl Server

#1
i'm kinda new in CodeIgniter, i'm trying to develop application that will have SQL server as the database.

my database.config :
PHP Code:
$db['default'] = array(
 
'dsn' => '',
 
'hostname' => '127.0.0.1',
 
       'port' => '1433',
 
'username' => 'dap',
 
'password' => '******'      
 
'database' => 'Dap_Db',
 
'dbdriver' => 'sqlsrv',
 
'dbprefix' => '',
 
'pconnect' => FALSE,
 
'db_debug' => FALSE,
 
'cache_on' => FALSE,
 
'cachedir' => '',
 
'char_set' => 'utf8',
 
'dbcollat' => 'utf8_general_ci',
 
'swap_pre' => '',
 
'encrypt' => FALSE,
 
'compress' => FALSE,
 
'stricton' => FALSE,
 
'failover' => array(),
 
'save_queries' => TRUE

); 

PHP Code:
my model 

class 
Sql_model extends CI_Model

{
 
   public function __construct() {
 
       parent::__construct();
 
   }
 
   
    function getAll
()
 
   {
 
       $query $this->db->get('Customers');
 
       return $query->result();
 
   }


PHP Code:
my controller :
class 
Test extends CI_Controller

{
 
   
    public 
function check()
 
   {
 
       $this->load->model('Sql_model');
 
       $arr $this->Sql_model->getAll();
 
      // $this->output->enable_profiler(TRUE);
 
       echo json_encode($arr);
 
   }



and also i dowload Microsoft Drivers 3.0 for PHP for SQL Server ver. 3.0  5.4  and  i'm using SQL server 2005.

but in the end i got this error :


Code:
A PHP Error was encountered

Severity: Warning
Message: sqlsrv_query() expects parameter 1 to be resource, boolean given
Filename: sqlsrv/sqlsrv_driver.php
Line Number: 199
Backtrace:
File: C:\xampp\htdocs\Dap_BluPrint\application\models\Sql_model.php
Line: 11
Function: get
File: C:\xampp\htdocs\Dap_BluPrint\application\controllers\Test.php
Line: 13
Function: getAll
File: C:\xampp\htdocs\Dap_BluPrint\index.php
Line: 292
Function: require_once
Reply

#2
The line number referenced in the error message doesn't line up with a call to sqlsrv_query() in the CI 3 releases. This makes me think that something in one or more of the files in your database library has been modified and may be the cause of the problem.

sqlsrv_query() is usually only called in _execute(), which is not usually used without checking the connection. However, there does appear to be one method in sqlsrv_driver (db_select()) which calls _execute() without checking the connection first, so there may be some potential for this to occur in an unmodified driver.
Reply

#3
Last night the problem was solve. just need to instal this "Microsoft SQL Server 2012 Native Client ODBC driver for x86". Now i can continue my project. Wish me guys... Big Grin
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.