Req #69695 [NEW]: It should be possible to use a foreach statement to build cases in a switch

From: Date: Sat, 23 May 2015 23:10:56 +0000
Subject: Req #69695 [NEW]: It should be possible to use a foreach statement to build cases in a switch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192841@lists.php.net to get a copy of this message
From:             joshua dot and dot delaine at gmail dot com
Operating system: OpenSuSE 13.2
PHP version:      5.6.9
Package:          Arrays related
Bug Type:         Feature/Change Request
Bug description:It should be possible to use a foreach statement to build cases in a switch

Description:
------------
I am co-author of a custom CMS and I have just recently started to go
back and revise it. I wanted to streamline the code to make the CMS not
care what the database structure it has to work with is. There are a
couple functions to get tables and get id fields and so-on, which rely
on switches. This is necessary for clean code, to say the least. As it
stands, I have to know in advance the table names, id fields, and
description fields to manually modify these functions for each install
of the CMS. It would be far superior if I could use an array generated
by querying the database for tables, only knowing the name of the
database. Additionally, as long as a coherent field name system was
adhered to, with specific key character groups in the names, it would be
possible to get the id and description fields with a slightly more
complicated database query on the tables returned to get the fields that
either ended in, for example "id" or "desc" to list all the id and
discription column names in an array to be used to generate the cases
for the respective switches in those functions as well.


---
From manual page: http://www.php.net/control-structures.switch
---


Test script:
---------------
The following link shows what one of the current functions looks like vs
what I'd like to be able to do. If this is already possible, please
forgive me. While a host on linux, I write code in Adobe Dreamweaver CS6
on a Windows box. It may have outdated syntax checking.

http://pastebin.com/qkyM7TS1

Actual result:
--------------
When I try to code it, Dreamweaver CS6 syntax checking breaks. It won't
do any more checking until the supposed syntax error is corrected. I
have not yet tried to put a test of the preferred method on my test
server.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=69695&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69695&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69695&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69695&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69695&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69695&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69695&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69695&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69695&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69695&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69695&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69695&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69695&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69695&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69695&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69695&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69695&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69695&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69695&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69695&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69695&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#192841) next »