Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我试图从SQL server在CodeIgniter中执行一个过程,我做错了什么?_Php_Sql Server_Codeigniter - Fatal编程技术网

Php 我试图从SQL server在CodeIgniter中执行一个过程,我做错了什么?

Php 我试图从SQL server在CodeIgniter中执行一个过程,我做错了什么?,php,sql-server,codeigniter,Php,Sql Server,Codeigniter,我试图从我的SQL server数据库执行存储过程并使其打印列表,打印列表的最佳方式是什么 这是我的模型: class Categories_Model extends CI_Model { public function __construct() { parent::__construct(); } function get_categories() { $sql = 'exec spGetCategoriesByID'; $query = $this->db

我试图从我的SQL server数据库执行存储过程并使其打印列表,打印列表的最佳方式是什么

这是我的模型:

class Categories_Model extends CI_Model
{
public function __construct()
{
    parent::__construct();
}

function get_categories()
{
    $sql = 'exec spGetCategoriesByID';
    $query = $this->db->query($sql);
    $result = $query->result();
    return $result;
}
}
这是我的控制器:

class Categories_Controller extends CI_Controller
{
public function __construct()
{
    parent::__construct();
    $this->load->helper('url');
    $this->load->database();
}

public function categories_list()
{
    $this->load->model('Categories_Model');
    $cat_result = $this->Categories_Model->get_categories();
    $data['catlist'] = $cat_result;
    $this->load->view('categories',$data);
}
}

尝试获取如下错误:

$query = $this->db->query($sql);
echo 'Error #'.$this->db->_error_number().': '.$this->db->_error_message();
die();

尝试获取如下错误:

$query = $this->db->query($sql);
echo 'Error #'.$this->db->_error_number().': '.$this->db->_error_message();
die();

不了解SQL server,但在Oracle中,只有函数才能返回数据,过程只能操作数据。假设您的sp不需要参数,请尝试$query=$this->db->query(“exec-spGetCategoriesByID()”`<代码>$this->categories\u model->get\u categories()和
$this->load->model('categories\u model')
应以小写字母书写;类名的第一个字母应该在文件名和此处大写:
class Categories\u model扩展了CI\u model
。谢谢,这确实有帮助。我不熟悉在php中使用mvc风格的框架。所以我感谢你的帮助!不了解SQL server,但在Oracle中,只有函数才能返回数据,过程只能操作数据。假设您的sp不需要参数,请尝试$query=$this->db->query(“exec-spGetCategoriesByID()”`<代码>$this->categories\u model->get\u categories()和
$this->load->model('categories\u model')
应以小写字母书写;类名的第一个字母应该在文件名和此处大写:
class Categories\u model扩展了CI\u model
。谢谢,这确实有帮助。我不熟悉在php中使用mvc风格的框架。所以我感谢你的帮助!