连接多个数据库的问题
时间:2011-11-30
来源:互联网
我的应用大部分是连mysql数据库的,现在需要连接到oralce数据库查询部分数据,我定义了一个model连接oracle的表:
<?php
class TestLogModel extends AdvModel{
/* 数据库设置 */
protected $connection = array(
'dbms' => 'oracle',
'username' => 'test',
'password' => 'test',
'hostname' => '127.0.0.1',
'hostport' => '1521',
'database' => 'TEST',
);
}
?>
在action中单独访问是正常的:
$TestLog = D('TestLog');
$list=$TestLog->limit(4)->select();
dump($list);
但是如果action中在$TestLog = D('TestLog');之前连过mysql的数据库就会有问题;例如:
$Aaa = M('Aaa');
$listaaa=$Aaa->find();
$TestLog = D('TestLog');
$list=$TestLog->limit(4)->select();
dump($list);
这样就取不到数据,【$Aaa = M('Aaa');连接的是mysql数据库,测过没有问题, 可以正常取数据。】
如果把$TestLog = D('TestLog');放到$Aaa = M('Aaa');的前面,就可以正常取到数据。
有谁遇到这种情况吗?谁能帮我解决下。。。万分感谢!
<?php
class TestLogModel extends AdvModel{
/* 数据库设置 */
protected $connection = array(
'dbms' => 'oracle',
'username' => 'test',
'password' => 'test',
'hostname' => '127.0.0.1',
'hostport' => '1521',
'database' => 'TEST',
);
}
?>
在action中单独访问是正常的:
$TestLog = D('TestLog');
$list=$TestLog->limit(4)->select();
dump($list);
但是如果action中在$TestLog = D('TestLog');之前连过mysql的数据库就会有问题;例如:
$Aaa = M('Aaa');
$listaaa=$Aaa->find();
$TestLog = D('TestLog');
$list=$TestLog->limit(4)->select();
dump($list);
这样就取不到数据,【$Aaa = M('Aaa');连接的是mysql数据库,测过没有问题, 可以正常取数据。】
如果把$TestLog = D('TestLog');放到$Aaa = M('Aaa');的前面,就可以正常取到数据。
有谁遇到这种情况吗?谁能帮我解决下。。。万分感谢!
作者: 21to5 发布时间: 2011-11-30
用getlastsql方法调试下最后执行的sql语句查下原因
作者: thinkphp 发布时间: 2011-11-30
$Aaa = M('Aaa');
$listaaa=$Aaa->find();
$TestLog = D('TestLog');
$list=$TestLog->limit(4)->select();
dump($list);
这个情况下getlastsql的结果如下:
bool(false)
SELECT * FROM `test_log` LIMIT 4
好像没有连接到oracle,而是到mysql中查找的【把limit(4)去掉也取不到数据】
$listaaa=$Aaa->find();
$TestLog = D('TestLog');
$list=$TestLog->limit(4)->select();
dump($list);
这个情况下getlastsql的结果如下:
bool(false)
SELECT * FROM `test_log` LIMIT 4
好像没有连接到oracle,而是到mysql中查找的【把limit(4)去掉也取不到数据】
作者: 21to5 发布时间: 2011-11-30
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28