Re: PHP 7.1 - Address PHPSadness #28?
| From: | Craig Francis | Date: | Fri, 02 Oct 2015 09:43:17 +0000 |
| Subject: | Re: PHP 7.1 - Address PHPSadness #28? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88639@lists.php.net to get a copy of this message | ||
While skim reading emails (just got back from holiday), I wanted to add...
On 23 Sep 2015, at 11:40, Rowan Collins <rowan.collins@gmail.com> wrote:
> A non-existent variable, however, is not something I've ever come across in a database
> context - it would seem to require a result set having rows with different numbers of columns.
Imagine an admin interface with a table of orders (showing customer name, date, link to view
details, etc).
Normally a simple SQL query can do this from 1 table (very fast).
But once a month the admin wants to see a new column (maybe checking if a particular product was in
each order), and that uses a slightly different query (joining a second table, which might be very
slow to execute).
In the view code (assuming no other helper for creating the HTML), it would be easier to read the
following than using array_key_extists():
<?php if (exists($row['special'])) { ?>
<td>...</td>
<?php } ?>
Admittedly I would probably use a variable to say if the column will be there or not (because there
is also the table headers to add).
That said, this probably doesn't really add to the use cases... but hopefully gives an example
of a non-existent variable in a database context.
Craig