While skim reading emails (just got back from holiday), I wanted to add...

On 23 Sep 2015, at 11:40, Rowan Collins <rowan.coll...@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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to