Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #12030

Re: from mysql in associative array

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: from mysql in associative array
Date 2013-11-29 23:56 +0000
Organization A noiseless patient Spider
Message-ID <l7b9it$20i$1@dont-email.me> (permalink)
References <l7abvs$k7s$1@dont-email.me> <l7acaj$ab9$1@softins.softins.co.uk> <l7achb$ab9$2@softins.softins.co.uk> <2908877.REXbavQy2K@PointedEars.de> <0.e54d0efc32c9fef1a5a2.20131129222630GMT.87k3fqyhd5.fsf@bsb.me.uk>

Show all headers | View raw


On Fri, 29 Nov 2013 22:26:30 +0000, Ben Bacarisse wrote:

> Thomas 'PointedEars' Lahn <PointedEars@web.de> writes:
> 
>> Tony Mountifield wrote:
>>> I wrote:

>>>> if ($sh) {
>>
>> Insufficient, RTFM.
> 
> Can you say why?

I'd guess tpel is postulating a resource with a non truthy value being 
returned from mysql_query, although I also note that reading the manual 
entry for mysql_query the section on return value does *_NOT_* contain 
the standard warning about valid false return values.

'if ($sh) {}' appears to be fine according to the manual, which also 
states that a resource is always truthy[1], unlike an int where 0 may be 
a valid response that would evaluate as false, or a string where "" or 
"0" could likewise be a valid return value which would evaluate to false.

The manual entry for array_search contains the following text in the 
return value section:

"Warning

This function may return Boolean FALSE, but may also return a non-Boolean 
value which evaluates to FALSE. Please read the section on Booleans for 
more information. Use the === operator for testing the return value of 
this function."

However the manual entry for mysql_query does not contain this warning.

Of course, tpel might have some other rationale and it's always possible 
he's not just talking out of his arse again.

[1] http://php.net/manual/en/language.types.boolean.php

" When converting to boolean, the following values are considered FALSE:

    the boolean FALSE itself
    the integer 0 (zero)
    the float 0.0 (zero)
    the empty string, and the string "0"
    an array with zero elements
    an object with zero member variables (PHP 4 only)
    the special type NULL (including unset variables)
    SimpleXML objects created from empty tags

Every other value is considered TRUE (including any resource). "

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

from mysql in associative array Knut Krueger <knut.krueger@usa.com> - 2013-11-29 16:31 +0100
  Re: from mysql in associative array tony@mountifield.org (Tony Mountifield) - 2013-11-29 15:36 +0000
    Re: from mysql in associative array tony@mountifield.org (Tony Mountifield) - 2013-11-29 15:40 +0000
      Re: from mysql in associative array The Natural Philosopher <tnp@invalid.invalid> - 2013-11-29 16:47 +0000
        Re: from mysql in associative array Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-29 14:06 -0500
      Re: from mysql in associative array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-29 21:29 +0100
        Re: from mysql in associative array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-29 22:26 +0000
          Re: from mysql in associative array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-29 23:36 +0100
          Re: from mysql in associative array Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-29 23:56 +0000
            Re: from mysql in associative array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-30 00:30 +0000
          Re: from mysql in associative array Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-29 20:29 -0500
        Re: from mysql in associative array tony@mountifield.org (Tony Mountifield) - 2013-11-30 13:35 +0000
          Re: from mysql in associative array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-30 15:28 +0100

csiph-web