Re: MySQL examples need review
| From: | Philip Olson | Date: | Sun, 23 Dec 2001 20:15:28 +0000 |
| Subject: | Re: MySQL examples need review | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969340316@lists.php.net to get a copy of this message | ||
> can you please give an example where 'or die()' is 'not flexible'.
I am referring to 'or' specifically. For example:
$conn = mysql_connect($host, $user, $pass) or die('Connection failed');
Okay that works. But let's say one wants to do multiple statements on
failure, the following will not work:
$conn = mysql_connect($host, $user, $pass) or {
doSomething();
die('Connection failed');
}
So later down the road when Sammy wants to doSomething() he'll need to
alter the whole statement. Instead, here's another way:
if (!$conn = mysql_connect($host, $user, $pass)) {
doSomething();
echo 'print stuff';
exit;
}
Or if (!$conn)... That is why I disagree with 'or' being a 'standard'
here. Are there ways around it? Yes. Is the above just an example?
Yep. IMHO :)
Regards,
Philip Olson