note 56311 added to function.odbc-exec

From: Date: Tue, 30 Aug 2005 13:18:49 +0000
Subject: note 56311 added to function.odbc-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-94425@lists.php.net to get a copy of this message
The following seems counterintuitive to me and so I am constantly getting burned by it. Just thought I'd add a note for anyone else who might also get burned. if (!odbc_exec("select MyValue from MyTable where Key1='x' and Key2='y'")) is not a good way to search for the existence of a record with Key1 = x and Key2 = y. The odbc_exec always returns a result handle, even though there aren't any records. Rather, you must use one of the fetch functions to find out that the record really doesn't exist. This should work: if (!($Selhand = odbc_exec("select MyValue from MyTable where Key1='x' and Key2='y'")) || !odbc_result($Selhand, 1)) ---- Manual Page -- http://www.php.net/manual/en/function.odbc-exec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56311 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56311&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56311&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56311&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56311&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56311&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56311&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56311&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94425) next »