You are here: Re: [PHP] php explained in sql « PHP « IT news, forums, messages
Re: [PHP] php explained in sql

Posted by Jose Miguel on 08/22/05 04:04

We should use:

if (!empty($mydata->email))

in php, right?

On 8/19/05, Jasper Bryant-Greene <jasper@bryant-greene.name> wrote:
> John Taylor-Johnston wrote:
> > In php, if I wanted to know if $mydata->email contained something, I
> > would do this, right?
> > if ($mydata->email)
> > {}
> >
> > How would I express this in SQL (MySQL)?
>
> That doesn't tell you if $mydata->email contains something. It tells you
> whether the value of $mydata->email, when cast to boolean, equals TRUE.
> If $mydata->email equaled zero or the string "0", it would still contain
> something, but that if statement would not get executed.
>
> In MySQL, it would depend on the datatype. You could do any of the
> following, depending on what you actually want to do:
>
> colname<>''
> colname<>0
> colname IS NOT NULL
>
> Or, if you're in MySQL >= 5.0.2 and are using true boolean values:
>
> colname IS TRUE
>
> or, if you just want to check if it's TRUE or UNKNOWN:
>
> colname IS NOT FALSE
>
>
> Jasper
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Jose Arce
http://sinexion.com - http://josearce.com

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация