1
votes

I connected SQL Server database successfully through CodeIgniter framework. I am able to use SQL queries directly but I want to use active record queries for fetching insertion or deletion then I get the following error:

"Call to undefined method CI_DB_sqlsrv_driver::select()"

What does that mean? I am not able to use active records when using SQL Server db ? Or is there any other active record library for it?
Can I use ACTIVE RECORDS of CodeIgniter for SQL Server? If yes, how?

This is not working:

$this->db->select('*');
$this->db->from('Persons');
$query = $this->db->get();
$data = $query->result();
print_r($data);

Only this way is working:

$db = $this->db->query('select * from Persons')->result();
print_r($db);
2
you should provide a litte bit more information - which CI version do you use ? post your database.php; Normally you should be able to use CI's Query Builder.but if you use some outdated version it might be possible that your driver isn't working... - sintakonte

2 Answers

2
votes

For More Info About Database Configuration

I tried with configuration change in application/config/database.php

$active_group = "default";
$active_record = TRUE;
$query_builder = TRUE;

and tried with clear cache.

0
votes

I you want to get all records than you don't need to write

$this->db->select('*');
$this->db->from('Persons');
$query = $this->db->get();
$data = $query->result();
print_r($data);

You can simply get by using

$query = $this->db->get('Persons');
$data = $query->result();
print_r($data);