Source for file northwind-mssql.php
Documentation is available at northwind-mssql.php
<title>ODBTP PEAR DB Example: MS SQL Server</title>
** This example shows how to connect to a MS SQL Server database
** using the PEAR DB driver for ODBTP.
$dsn = 'odbtp(mssql)://myuid:mypwd@odbtphost/NorthWind?server=mysrvr&rowcache=yes';
// The following DSN specification can be used if the ODBTP server
// and SQL Server reside on the same host machine.
// $dsn = 'odbtp(mssql)://myuid:mypwd@mysrvr/NorthWind?rowcache=yes';
$options['persistent'] = true;
$dbh = DB ::connect ( $dsn, $options );
if( PEAR ::isError ( $dbh ) ) {
echo "Error message: " . $dbh->getMessage () . "<br>\n";
echo "Detailed error description: " . $dbh->getDebugInfo () . "<br>\n";
// FOR BROWSE allows table names to be included in results
$sql = "SELECT * FROM Customers AS C, Orders AS O "
. "WHERE O.CustomerId = C.CustomerId FOR BROWSE";
$res = $dbh->query ( $sql );
if( PEAR ::isError ( $res ) ) {
echo "Error message: " . $res->getMessage () . "<br>\n";
echo "Detailed error description: " . $res->getDebugInfo () . "<br>\n";
if( !($cols = $res->numCols ()) ) continue;
echo $res->numRows () . " rows<p>\n";
$colinfo = $res->tableInfo ();
if( PEAR ::isError ( $colinfo ) ) {
echo "Error message: " . $colinfo->getMessage () . "<br>\n";
echo "Detailed error description: " . $colinfo->getDebugInfo () . "<br>\n";
echo "<table cellpadding=2 cellspacing=0 border=1>\n";
echo "<td> <b>Table</b> </td>";
echo "<td> <b>Name</b> </td>";
echo "<td> <b>Type</b> </td>";
echo "<td> <b>Length</b> </td>";
echo "<td> <b>Flags</b> </td>";
for( $i = 0; $i < $cols; $i++ ) {
echo "<td> ". $colinfo[$i]['table'] . " </td>";
echo "<td> ". $colinfo[$i]['name'] . " </td>";
echo "<td> ". $colinfo[$i]['type'] . " </td>";
echo "<td> ". $colinfo[$i]['len'] . " </td>";
echo "<td> ". $colinfo[$i]['flags'] . " </td>";
echo "<table cellpadding=2 cellspacing=0 border=1>\n";
for( $col = 0; $col < $cols; $col++ ) {
echo "<td><nobr> " . $colinfo[$col]['name'] . " </nobr></td>";
while ( $row = $res->fetchRow () ) {
for( $col = 0; $col < $cols; $col++ ) {
if( is_null( $row[$col] ) ) $row[$col] = "NULL";
echo "<td valign=\"top\"><pre>";
while ( $res->nextResult () );
Documentation generated on Mon, 11 Mar 2019 15:32:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|