Re: RES: Re: Need help to understand a code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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');


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux