Re: PROGRESS SQL_CUR_USE_ODBC

From: Date: Tue, 04 Oct 2005 18:27:21 +0000
Subject: Re: PROGRESS SQL_CUR_USE_ODBC
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-223620@lists.php.net to get a copy of this message
cybermalandro cybermalandro wrote:
Thanks for your prompt response! Are you using the pear DB class requiring odbc? I am not very familiar with this class and pear. I was trying to do it the old way. Perhaps you can give me some more examples? I really appreciate your help. Thanks On 10/4/05, *Kristen G. Thorson* <kthorson@allegroconsultants.com <mailto:kthorson@allegroconsultants.com>> wrote:
    cybermalandro cybermalandro wrote:
I am connecting to a PROGRESS DB through the MERANT ODBC driver,
    When I have
the 4th parameter SQL_CUR_USE_ODBC as shown, my queries return
    nothing but
if I have the 4th parameter as lower case it returns my query
    results but
with a PHP error complainning *Notice*: Use of undefined constant sql_cur_use_odbc - assumed 'sql_cur_use_odbc' Wtf? I don't get it, most of the documentation from people
    connecting to
PROGRESS do have the 4th parameter uppercase can someone help me
    out ?
Thanks!
    Using PEAR:DB with this dsn I can connect and get results:
    $dsn =
    "odbc(Progress_SQL92_Driver)://$username:$password@$protocol+$ip:$port/$database?cursor=SQL_CUR_USE_ODBC";
    kgt
I think I was using iODBC and the PEAR DB class. I actually did this a long time ago. I have this script sitting on my hard drive and I know I had a working solution at one point in time, so I'm assuming this was it. I don't have the test environment set up anymore, so I can't really check. Following is the script I have to print the contents of the Customer table in the Sports database. It looks like I took a PEAR:DB example and just modified it to work with Progress, so I'm certain there's much room for improvement.
require_once '/usr/share/pear/DB.php';    
// Get the connection variables: require_once 'dbinfo.php'; $dsn = "odbc(Progress_SQL92_Driver)://$username:$password@$protocol+$ip:$port/$database?cursor=SQL_CUR_USE_ODBC"; // Creates a database connection object in $db or, a database error object if it went wrong. // The boolean specifies this is a persistent connection like mysql_pconnect(), it // defaults to FALSE. $db = DB::connect($dsn, TRUE); // Check whether the object is a connection or
if (DB::isError($db)) {             /*
    * This is not what you would really want to do in
    * your program.  It merely demonstrates what kinds
    * of data you can get back from error objects.
    */
echo 'Standard Message: ' . $db->getMessage() . "<br>\n"; echo 'Standard Code: ' . $db->getCode() . "<br>\n"; echo 'DBMS/User Message: ' . $db->getUserInfo() . "<br>\n"; echo 'DBMS/Debug Message: ' . $db->getDebugInfo() . "<br>\n"; exit;
                               // an error.
   //die($db->getMessage());     // Print out a message and exit if it's
                               // an error object.
} // Get a connection as above $sql = "SELECT * from PUB.Customer"; // Build your SQL query $res = $db->query($sql);
if (DB::isError($res)) {        // Check the result object in case there
   die($res->getMessage());    // was an error, and handle it here.
} echo "<table cellpadding=0 cellspacing=0 border=0>"; echo "<tr><th>Cust Num</th>"; echo "<th>Name</th>"; echo "<th>Address</th>"; echo "<th>Address2</th>"; echo "<th>City</th>"; echo "<th>State</th>"; echo "<th>Country</th>"; echo "<th>Phone</th>"; echo "<th>Contact</th>"; echo "<th>Sales-Rep</th>"; echo "<th>Comments</th>"; echo "<th>Credit-Limit</th>"; echo "<th>Balance</th>"; echo "<th>Terms</th>"; echo "<th>Discount</th>"; echo "<th>Postal-Code</th></tr>"; while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { // Fetch a row from the result resource object $res. // DB_FETCHMODE_OBJECT returns a row with column names as keys. // Other possibilities are listed here: // http://pear.php.net/manual/en/core.db.tut_fetch.php if (DB::isError($row)) {
       //fetchRow can return an error object like most PEAR::DB methods
       die($row->getMessage());
} else {
       echo "<tr><td>" . $row["Cust-Num"] . "</td>\n";
       echo "<td>" . $row["Name"] . "</td>\n";
       echo "<td>" . $row["Address"] . "</td>\n";
       echo "<td>" . $row["Address2"] . "</td>\n";
       echo "<td>" . $row["City"] . "</td>\n";
       echo "<td>" . $row["State"] . "</td>\n";
       echo "<td>" . $row["Country"] . "</td>\n";
       echo "<td>" . $row["Phone"] . "</td>\n";
       echo "<td>" . $row["Contact"] . "</td>\n";
       echo "<td>" . $row["Sales-Rep"] . "</td>\n";
       echo "<td>" . $row["Comments"] . "</td>\n";
       echo "<td>" . $row["Credit-Limit"] . "</td>\n";
       echo "<td>" . $row["Balance"] . "</td>\n";
       echo "<td>" . $row["Terms"] . "</td>\n";
       echo "<td>" . $row["Discount"] . "</td>\n";
       echo "<td>" . $row["Postal-Code"] . "</td></tr>\n";
} } echo "</table>"; $res->free();
$db->disconnect();              // Close the connection.


« previous php.general (#223620) next »