Re: DB::connect

From: Date: Wed, 12 Feb 2003 17:46:57 +0000
Subject: Re: DB::connect
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-3716@lists.php.net to get a copy of this message
Sounds like sybase support is missing from your version of PHP. Did you compile PHP with the --with-sybase-ct[=DIR] option? On Wed, 12 Feb 2003, César Arnold wrote: > Hi, > I'm starting to use the Pear DB in a Windows 2000 > platform, and I'm getting a message when trying to > connect to a Sybase database. > > I got the code sample from Tomas V.V Cox, and did some > changes to my specific case. When I ran the page it > stops after trying to connect, on the line " die( > $db->getMessage());" and gives the following mesage: > > DB Error: extension not found > > > The code is here: > > <?php > > // The pear base directory must be in your > include_path > require_once 'DB.php'; > > $sgdb = 'sybase'; > $user = 'testeida'; > $pass = 'teste123'; > $host = 'SOL_DB'; > $db_name = 'ida_teste'; > > // Data Source Name: This is the universal connection > string > > $dsn = "$sgdb://$user:$pass@$host/$db_name"; > echo $dsn; > > // DB::connect will return a Pear DB object on success > // or a Pear DB Error object on error > // You can also set to TRUE the second param > // if you want a persistent connection: > // $db = DB::connect($dsn, true); > > > $db = DB::connect($dsn); > > > if (DB::isError($db)) > { > // get the native backend error > // and the last query > die( $db->getMessage()); > } > > // With DB::isError you can differentiate between an > error or > // a valid connection. > > // Once you have a valid DB object... > $sql = "select CodigoDoPais, NomeDoPais from PAIS"; > > // If the query is a "SELECT", $db->query will return > // a DB Result object on success. > // Else it simply will return a DB_OK > // On failure it will return a DB Error object. > > if (DB::isError($result = $db->query($sql))) > { > // get the native backend error > // and the last query > echo $result->getMessage(); > } > > > // Always check that $result is not an error > if (DB::isError($result)) > { > die ($result->getMessage()); > } > > // this will set a default fetchmode for this Pear DB > instance > // (for all queries) > > while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) > { > echo $row['NomeDoPais'] . "<br>"; > } > > // You can disconnect from the database with: > $db->disconnect(); > ?> > > Someone can help me? > Thanks. > > _______________________________________________________________________ > Busca Yahoo! > O serviço de busca mais completo da Internet. O que você pensar o Yahoo! encontra. > http://br.busca.yahoo.com/ > > -- Tony Bibbs "I guess you have to remember that those who don't tony@tonybibbs.com hunt or fish often see those of us who do as harmlessly strange and sort of amusing. When you think about it, that might be a fair assessment." --Unknown

« previous php.pear.general (#3716) next »