English 中文(简体)
CakePHP and connecting to MS Access db using Unixodbc
原标题:

I m trying to use an Acces (MDB) database from a CakePHP app. On a Windows machine this works fine. On a Linux machine using Unixodbc this doesn t work at all. The error is as follows:

Warning (2): odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver anager]Data ource name not found, and no default driver specified, SQL state IM002 in SQLConnect [APP/vendors/adodb/drivers/adodb-odbc.inc.php, line 60]

The CakePHP datasource definition is:

             $default = array(
                             driver  =>  adodb ,
                             connect   =>  access ,
                             host  => "Driver=[MDBODBC]; Dbq=".$filePath.";Uid=Admin;Pwd=;}",
                             login     =>  Admin ,
                             password  =>   ,
                             database  =>   
                    );

What s wrong with this configuration?

问题回答

The host element looks odd in general because of its unmatched closing brace.

How does the line number 60 (from the error message) look in dodb-odbc.inc.php? Which elements of the configuration array does it use for the call to odbc_connect? Compare the call to the examples for the odbc_connect documentation.

Have you tried connecting using odbc_connect directly?

As an aside, my version of cake has an ODBC DBO driver actually within the cake framework, at

cake/libs/model/dbo/dbo_odbc.php

It uses odbc_pconnect. There, the $dsn string that is the first argument to odbc_pconnect comes from the database element of the config array, not the host element.

I don t know why you would use a third party solution in

app/vendors/adodb/drivers/adodb-odbc.inc.php

especially since the Date Library in John Lim ADOdb Library for PHP allows remote attackers to obtain sensitive information.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签