当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Codeigniter Active Record inside custom library class

问题描述:

My function breaks at the line where I make an Active Record call, so I must not be calling things right.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Class Stuff {

public function specific($passedArray) {

echo "Test";

$CI =& get_instance();

$CI->load->database();

$CI->load->helper('array');

$CI->load->helper('format_helper');

$dataArray = $this->db->where($column_name, $StockNum);

$dataArray = $this->db->get($tablename);

echo "Bollocks!";

"Test" will echo, but not Bollocks!

网友答案:

You should be using $CI->db->... not $this->db

网友答案:

Try the code below

$db = $CI->load->database();
$dataArray = $db->where($column_name, $StockNum);
$dataArray = $db->get($tablename);
分享给朋友:
您可能感兴趣的文章:
随机阅读: