Re: RES: [PHP] Re: Need help to understand a code

From: Date: Sat, 22 Sep 2012 14:52:36 +0000
Subject: Re: RES: [PHP] Re: Need help to understand a code
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-319201@lists.php.net to get a copy of this message
On 22-09-2012 16:19, Samuel Lopes Grigolato wrote:
+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.
If you're doing it that way, just use mysqli and then mysqli_result's fetch_object with your Entity as the class. ie: $result = $mysqli->query('some query'); $entity = $result->fetch_object('Entity');

« previous php.general (#319201) next »