Functions returning opposite than expected
| From: | Tyson Lloyd Thwaites | Date: | Fri, 01 Sep 2000 00:31:43 +0000 |
| Subject: | Functions returning opposite than expected | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2543@lists.php.net to get a copy of this message | ||
Hi all,
I am still having fun and games with functions returning the opposite of
what I expect.
Example:
if (!preg_match('/SELECT/i', $this->qry)) {
echo "TRACE: select";
while (odbc_fetch_row($this->qry))
$this->rowcount++; }
} else {
echo "TRACE: action";
$this->rowcount = odbc_num_rows($this->qry);
}
Please note that '!' in front of preg_match. If I leave it off (which would
make sense, right?) it branches to the wrong part, ie if I run a select
query, it would branch to the action part and vice versa. I have had to
negate a few functions in tests like that, and I think that either I'm
missing something embarrasingly obvious (like, I'm mad) or PHP is doing some
wierd stuff.
Another thing I tried doing is this:
if (preg_match('/select/i', $this->qry)==true) {
But sure enough, unless I change the true to false, I get the opposite of
what I expect.
Please help! And try to be nice to me if it's a stupid mistake! ;)
Regards,
Tyson Lloyd Thwaites
IT&e Ltd