自定义库类中的Codeigniter Active Record

时间:2010-07-27 16:27:33

标签: php activerecord codeigniter

我的功能在我进行Active Record呼叫的行中断,所以我不能正确地调用它。

<?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!";

“测试”会回响,但不是Bollocks!

2 个答案:

答案 0 :(得分:2)

您应该使用$ CI-&gt; db-&gt; ...而不是$ this-&gt; db

答案 1 :(得分:0)

尝试以下代码

$db = $CI->load->database();
$dataArray = $db->where($column_name, $StockNum);
$dataArray = $db->get($tablename);
相关问题