| 
	
 | 
 Posted by Mike Walsh on 05/26/05 06:25 
"ljb" <ljb220@mindspring.com.nospam> wrote in message 
news:qO8le.7819$M36.3928@newsread1.news.atl.earthlink.net... 
> mike_walsh@mindspring.com wrote: 
 
[ ... snipped ... ] 
 
> 
> If you were developing on Unix/Linux, I would suggest using freetds for 
the 
> low-level library. On Windows, it might be better to use the PHP ODBC 
> extension instead of the PHP sybase_ct extension.  Can your application 
use 
> ODBC instead? But the general answer to your question is that the 
low-level 
> library like libct.dll (or ODBC) has to come with the database software. 
> No, Sybase doesn't make it available separately as far as I know, and in 
> fact they don't even make it easy to find out how to buy it (apart from 
> being included in the database product). But if your Windows box can talk 
> to the database (with Sybase central, for example) then it already has the 
> low-level ODBC drivers from Sybase, and PHP should be able to use those 
> with the ODBC extension. 
 
Can you elaborate on freetds?  The application is developed on a Windows 
environment but will be deployed on a Sun so I actually need to solve both 
problems. 
 
I have actually started looking into the ODBC solution and have been able to 
create a connection via Excel so I assume I can use the same datasource for 
PHP.  However, I am struggling with how exactly to make this work. 
 
I have set up an ODBC Data Source using Windows XP's Data Source (ODBC) 
Control Panel utility.  I am able to connect to the database without any 
problem.  I have given this datasource a name "Sample Data Source". 
 
Now how would I create the proper connection with PHP?  I am using PEAR DB 
and did the following: 
 
//The hostname that has the Database 
define("DB_HOSTNAME", "odbc.server.com"); 
define("DB_PORT", "1000"); 
 
//The username and password 
define("DB_USERNAME", "db_username"); 
define("DB_PASSWORD", "db_password"); 
 
//The DB name to use 
define("DB_NAME", "sample_database"); 
 
//The DB DSN 
define("DB_DSN", "odbc://" . DB_USERNAME . ":" . DB_PASSWORD . "@" . 
DB_HOSTNAME . ":" . DB_PORT . "/" . DB_NAME) ; 
 
$dbh = DB::connect(CQ_DB_DSN, true) ; 
 
if (DB::isError($dbh)) 
{ 
    die(sprintf("%s(%s):  %s", basename(__FILE__), __LINE__, 
$dbh->getMessage())) ; 
} 
else 
{ 
    print "Database connection successful." ; 
} 
 
$dbh->disconnect() ; 
 
The values in the PHP defines are the same as those I used to create the 
ODBC connection via the Windows Control Panel.  Should my DSN reference the 
name I used to create the ODBC connection?  What would a valid DSN then look 
like? 
 
Thanks for any guidance. 
 
Mike 
 
 
--  
Mike Walsh - mike_walsh at mindspring.com
 
[Back to original message] 
 |