Get Data From Stored Procedure Using Sqlsrv Driver Get Data From Stored Procedure Using Sqlsrv Driver codeigniter codeigniter

Get Data From Stored Procedure Using Sqlsrv Driver


First of all, if you are using Codeigniter, I recommend use their database class to connect to MSSQL Server. You can read more on this here: http://ellislab.com/codeigniter/user-guide/database/configuration.html

If you aren't auto-connecting to your database you can connect like this: $this->load->database('default');

Once you have your configuration setup, you can have a function like this in your model:

function login($username, $password) {    return $this->db->query("EXEC spLogin '$username', '$password'")->result();}


oh..............after long RND I got ans

PhpService.php:

    public function Login($username, $password)    {        $this->load->model('Apimodel');        $result = $this->Apimodel->Login($username,$password);        header('Content-type: application/json');        echo json_encode(array('LoginResponce'=>$result));    }

apimodel.php:

function Login($username, $password)    {        $this->db = $this->GetDB();        $query =  $this->db->query("EXEC Login $username,$password");        return $query->result();    }