Jig*_*Raj 6 php rest stored-procedures codeigniter sql-server-2008
我SQL server2008
用作数据库,我已经编写了存储过程MSSQL Server 2008
.它运作良好MSSQL Server 2008
.我想从中调用此存储过程codeigniter
.为此我写了这样的代码:
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));
}
Run Code Online (Sandbox Code Playgroud)
apimodel.php:
function Login($UserName,$Password)
{
$this->db = $this->GetDB();
$query = $this->db->query("EXEC Login");
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
当我执行没有参数的过程时,它工作正常
function Login($UserName,$Password)
{
$this->db = $this->GetDB();
$query = $this->db->query("EXEC Login '$UserName','$Password'");
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
但是,当我使用参数执行过程时它不起作用
谁能告诉我,我在这里失踪了什么?
提前致谢
哦............经过长时间的RND我得到了答案
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));
}
Run Code Online (Sandbox Code Playgroud)
apimodel.php:
function Login($username, $password)
{
$this->db = $this->GetDB();
$query = $this->db->query("EXEC Login $username,$password");
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5377 次 |
最近记录: |