note 39618 added to function.odbc-connect
| From: | atze at o2o dot com dot au | Date: | Wed, 04 Feb 2004 20:41:32 +0000 |
| Subject: | note 39618 added to function.odbc-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64651@lists.php.net to get a copy of this message | ||
To connect to a SQL DB on a unix srv via odbc one can use one of the following solutions.
1. having an odbc.ini (~/.odbc.ini)
[PostgreSQL]
Description = PostgreSQL template1
Driver = PostgreSQL
Trace = Yes
TraceFile = /tmp/odbc.log
Database = PerfTest
Servername = localhost
UserName = boss
Password = BigBoss
Port = 5432
Protocol = 6.4
ReadOnly = Yes
ConnSettings =
[Default]
Driver = /local/lib/libodbc.so
2. specifying a DSN
function DBCALL($SQL)
{
$U = "boss";
$DB = "PerfTest";
$P = "BigBoss";
$Srv = "llocalhost";
$DSN = "Driver=PostgreSQL;Server=$Srv;Database=$DB";
echo "Trying to connect to $DSN\n";
if ($CID = odbc_connect ("$DSN","$U","$P",SQL_CUR_USE_ODBC))
{
echo "still trying CID = $CID\n";
if ($RES = odbc_exec($CID, $SQL))
{
echo "RES = $RES\n";
print_r($RES);
echo "\n";
$NR = odbc_num_rows($RES);
<snip>
Hope this helps.
----
Manual Page -- http://www.php.net/manual/en/function.odbc-connect.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39618
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39618&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39618&report=yes
Search -- http://master.php.net/manage/user-notes.php