Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.3

Bug #49 sybase simpleQuery is broken
Submitted: 2003-09-30 11:56 UTC
From: r dot vanicek at seznam dot cz Assigned: danielc
Status: Closed Package: DB
PHP Version: 4.3.3 OS: Debian GNU/Linux woody
Roadmaps: (Not assigned)    
Subscription  


 [2003-09-30 11:56 UTC] r dot vanicek at seznam dot cz
Description: ------------ simpleQuery method in the sybase class always returns an error. I have discovered that the problem is caused by the sybase_select_db call which always fails with the message: Warning: sybase_select_db(): Sybase message: Incorrect syntax near 'use'. (severity 15) in /usr/local/lib/php/DB/sybase.php on line 220 The fix is to comment out the if statement, because it is not needed (the database is already selected, after calling connect). The previous version (RC1) did not have this statement (select_db) inside the simpleQuery and my opinion is that it should not be here (it is strange to change the db with every command). I hope your day goes well, Roman Reproduce code: --------------- require_once "DB.php"; $GLOBALS['dsn'] = array( 'phptype'=>'sybase', 'username'=>'user', 'password'=>'PSWD', 'hostspec'=>'servername', 'database'=>'dbname', 'charset'=>'iso-8859-2'); $GLOBALS['kkDB'] = @DB::connect($GLOBALS['dsn'],false); $GLOBALS['kkDB']->query('set dateformat dmy'); $res = $kkDB->query("select * from ANYTABLE"); var_dump($res);

Comments

 [2003-11-14 14:09 UTC] fielker at informatik dot fh-augsburg dot de
Hi i found out where the problem is: simple_query mages use of "$this->_db" which is not initalized. So I looked at the mysql code. In connect() $this->_db is set to $dsninfo['database']. So here the fix. Pleas PEAR guys add this to the next release of DB. THX. if ($dsninfo['database']) { if (!@sybase_select_db($dsninfo['database'], $conn)) { return $this->raiseError(DB_ERROR_NODBSELECTED, null, null, null, sybase_get_last_message()); } } if ($dsninfo['database']) { if (!@sybase_select_db($dsninfo['database'], $conn)) { return $this->raiseError(DB_ERROR_NODBSELECTED, null, null, null, sybase_get_last_message()); } $this->_db = $dsninfo['database']; // -<<<<<<<<<<<<<<<<<< ADD THIS (line 114) }
 [2003-11-20 17:49 UTC] trevor dot dennis at eds dot com
Even with the code fix given, you must now still pass the database name to the connect string where you didn't have to before. Normally one relies on Sybase to automatically place you in your correct default database upon connection based on the user login name. Maybe the connect code should query the current database if it was not defined on the DSN string. select db_name() I agree with the first statement though. It should not be setting the database before every simple query. This may cause issues with transactions or at the very least will slow down processing if you're doing a large many row insert.
 [2003-12-16 05:03 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2003-12-31 05:15 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!