惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

PCI Perspectives
PCI Perspectives
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
V
Visual Studio Blog
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Security Affairs
S
SegmentFault 最新的问题
C
Cisco Blogs
博客园 - 聂微东
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
量子位
T
The Exploit Database - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Latest
Security Latest
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog

博客园 - wasd

pear安装步骤 linux定时任务的设置 C语言字符串拆分,打开关闭文件 - wasd - 博客园 js-tips 用optgroup 禁用select中的option方法 - wasd - 博客园 DB2常用语句记录 addslashes、get_magic_quotes_gpc函数、stripslashes函数(转来记录一下) - wasd - 博客园 Linux 强制卸载软件 - wasd - 博客园 Setup locally visual host - wasd B:X星球的身份证系统 B:有道搜索框 B:有道饭团 A:另类的异或 C:Sibonacci - wasd - 博客园 PHP 的变量 - wasd - 博客园 DB2 SQLSTATE 消息异常 JDBC中Preparedstatement使用小结 及JDBC插入数据后获得Last insert ID 并行计算简介 PB3编译adobe的例子photoviewer时错误处理
CakePHP支持DB2
wasd · 2010-05-24 · via 博客园 - wasd

研究了一个下午ThinkPHP2.0,终于弄明白了,却发现不支持DB2,有人说PDO可以用于连接DB2,我试过之后发现最新的ThinkPHP2.0的PDO驱动里面有很低级的bug,试了一晚上始终没有用PDO连上DB2。有可以用ThinkPHP+DB2开发的朋友请指教。

然后尝试CakePHP,下载最新的1.3发现里面没有DB2的驱动,去SVN地址check出来的代码是有的,放弃最新版,就用check出来的吧,版本号1.2.4.8284

我的配置是这样的,DB2安装在远程的服务器上,也是我们开发服务器,但是调试在本地。Apache+PHP+DB2。

参考http://krook.net/archives/180 database.php 配置,发现还是不可以,不知道是不是和我的环境有关。

还好可以trace到lib里面的PHP代码,看了看dbo_db2.php发现还有一个配置数组,还多了些参数:

 1     var $_baseConfig = array(
 2         'persistent'     => true,
 3         'login'         => 'db2inst1',
 4         'password'         => '',
 5         'database'         => 'cake',
 6         'schema'        => '',
 7         'hostname'        => '127.0.0.1',
 8         'port'            => '50001',
 9         'encoding'        => 'UTF-8',
10         'cataloged'        => true,
11         'autocommit'    => true
12     );

再往下看代码发现有两种连接数据库的办法:

 1         if ($config['cataloged']) {
 2             $this->connection = $connect($config['database'], $config['login'], $config['password']);
 3         } else {
 4             $connString = sprintf(
 5                 "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=%s;HOSTNAME=%s;PORT=%d;PROTOCOL=TCPIP;UID=%s;PWD=%s;",
 6                 $config['database'],
 7                 $config['hostname'],
 8                 $config['port'],
 9                 $config['login'],
10                 $config['password']
11             );
12             $this->connection = db2_connect($connString, '', '');
13         }

默认情况 $config['cataloged']为真,连接失败,将此值强制写入配置数据,搞定了,终于连上数据库了,呵呵,那就先用Cakephp玩玩吧。

贴出我的配置文件  database.php 给大家参考一下

 1     var $default = array(
 2         'driver' => 'db2',
 3         'persistent' => false,
 4         'hostname' => '123.456.789.012',
 5         'login' => 'db2inst1',
 6         'password' => 'password',
 7         'database' => 'CAKE',
 8         'port' =>50000,
 9         'cataloged' => false,
10         'prefix' => '',
11     );

 注意:如果你的DB2和默认配置不一样的话,都要在这里把不一样的配置参数写出来。