RES: [PHP] Re: Need help to understand a code
| From: | Samuel Lopes Grigolato | Date: | Sat, 22 Sep 2012 14:19:21 +0000 |
| Subject: | RES: [PHP] Re: Need help to understand a code | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319199@lists.php.net to get a copy of this message | ||
+1 to bad maintainability of the code.
As a suggestion, one better solution could be something like:
[...]
class Entity {
public $id;
public $name;
}
[...]
$entity = new Entity();
foreach [...]
$entity->$$key = $value;
[...]
And, of course, never ever use "*" in SQL queries.
Samuel.
-----Mensagem original-----
De: Matijn Woudt [mailto:tijnema@gmail.com]
Enviada em: sábado, 22 de setembro de 2012 11:02
Para: ash@ashleysheridan.co.uk
Cc: Ashickur Rahman Noor; PHP List
Assunto: Re: [PHP] Re: Need help to understand a code
Op 22 sep. 2012 13:47 schreef "Ashley Sheridan" <ash@ashleysheridan.co.uk> het
volgende:
>
> On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:
>
> > Hi Ashley
> >
> > I am updating some one code. Thanks for the notify.
> >
> > Thanks to all. Now I get that.
> > ----------------------------------------------------------
> > Dedicated Linux Forum in Bangladesh
> > <http://goo.gl/238Ck>
> > 2048R/89C932E1 <http://goo.gl/TkP5U> Coordinator -
> > Public Relation
> > Cell, FOSS Bangladesh <http://fossbd.org/>
> > && Mozilla Reps
> > <http://reps.mozilla.org> 01199151550, 01551151550
>
>
> It's probably fine doing that for your example, as the content coming
> from the database will be content you expect, but be wary of using it
> on any of the user-generated arrays like $_GET, or $_POST.
>
And a few months/years later you decide to add a new column to your db which has the same name as
one of the variables you're already using and the script starts acting very strange...
People should stop using bad coding habits like these..
- Matijn