note 25225 added to function.mysql-fetch-object
| From: | Federico at Pomi dot net | Date: | Sun, 15 Sep 2002 12:41:29 +0000 |
| Subject: | note 25225 added to function.mysql-fetch-object | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36697@lists.php.net to get a copy of this message | ||
Be carefull:
the object returned will be a new/fresh object.
You can't use this function to replace some attributes of an existing object keeping the old
ones.
Example:
class person
{
var $name;
var $surname;
var $doh;
function print()
{
print($name." ".$surname);
}
function get_from_db()
{
$res=query("select name, surname from ppl where... limit 1");
$this=mysql-fetch-object($res);
}
}
This won't work! When the method get_from_db() is executed, your old object will be
destroyed... you won't find anything in the attribute $doh, and if you'll try to call the
method print(), it will say it doesn't exist.
--
http://www.php.net/manual/en/function.mysql-fetch-object.php
http://master.php.net/manage/user-notes.php?action=edit+25225
http://master.php.net/manage/user-notes.php?action=delete+25225
http://master.php.net/manage/user-notes.php?action=reject+25225