note 56585 added to ref.pdo-dblib
| From: | graham1 dot simpson at hsbcib dot com | Date: | Thu, 08 Sep 2005 07:19:01 +0000 |
| Subject: | note 56585 added to ref.pdo-dblib | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94891@lists.php.net to get a copy of this message | ||
There is currently little sybase related PDO docs out there. The ones that I found often mention a
spec for a dsn that is invalid. Here's how I am currently connecting to sybase ASE:
1. Compile up freetds http://www.freetds.org on top of open
client;
2. Add the PDO and PD_DBLIB modules to php 5 as per the documentation; Note: I'm currently
using the PDO-beta and PDO_DBLIB-beta;
3. Check mods installed ok using "pear list" and "php -m";
The documentation often says to use "sybase:" as your DSN, this doesn't work. Use
"dblib:" instead. Here's an example:
<?php
try {
$hostname = "myhost";
$port = 10060;
$dbname = "tempdb";
$username = "dbuser";
$pw = "password";
$dbh = new PDO
("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
$stmt = $dbh->prepare("select name from master..sysdatabases where name =
db_name()");
$stmt->execute();
while ($row = $stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
?>
Hope this helps.
----
Manual Page -- http://www.php.net/manual/en/ref.pdo-dblib.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56585
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56585&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56585&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56585&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56585&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56585&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56585&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56585&report=yes
Search -- http://master.php.net/manage/user-notes.php