|
问题:“在模板里定义了两个不同的方法(m1,m2),功能是取不同表内容;控制器的一个方法cf_m1调用m1,m2,而结果却是:m2返回的结果m1相同”。
但我换成mysql,则正常(取出了不同的数据)各代码如下:
数据库配置代码:(数据库连接正常)
$host = '192.168.0.1';
$port = '1521';
$sid = 'testdb';
$NLS_LANG = "NA";
$tns = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT= 1521)))(CONNECT_DATA=(SID = $sid)(SERVER = DEDICATED)))";
$db['default']['hostname'] = $tns;
$db['default']['username'] = "root";
$db['default']['password'] = "123456";
$db['default']['database'] = "testdb";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";
控制器代码:
class MyController extends Controller
{
function MyController()
{
parent::Controller();
$this->load->model('myModelDir', 'MyModel');
return;
}
function cf_m1()
{
$data['data1'] = $this->MyModel->m1();//return array
$data['data2'] = $this->MyModel->m2();//return array
print_r($data['data1']);
/*问题就在这,两次打印出来的结果是一样的可如果换成是Mysql,MSSQL则返回不同的结果*/
print_r($data['data2']);
$this->load->view('myView', $data);
}
}
模式文件代码:
class MyModel extends Model
{
function MyModel()
{
parent::Model();
}
function m1()
{
$query1 = '';
$data1 = array();
$query1 = $this->db->query("select * from tb1");//table 1
$data1 = $query1->row_array();
$query1->free_result();
return $data1;
}
function m2()
{
$query2 = '';
$data2 = array();
$query2 = $this->db->query("select * from tb2");//table 1
$data2 = $query2->row_array();
$query2->free_result();
return $data2;
}
} |
|