09-21-2015, 09:19 PM
i'm kinda new in CodeIgniter, i'm trying to develop application that will have SQL server as the database.
my database.config :
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 :
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