mysql_fetch_object & classes
Posted: Sat Nov 21, 2009 1:16 pm
Hello
I'm trying to retrieve information from Mysql using mysql_fetch_object and store each row as an object.
I know that I can use something like this, but is not stored in my class
while ($row = mysql_fetch_object($result))
{
echo $row->id;
}
I need to store the fields in a class to make some changes in the values.
class className{
var $newId;
function className()
{
$this->newId = $id + 100;
}
}
while ($row = mysql_fetch_object($result, "className"))
{
echo $row->newId;
}
The thing is that the constructor of the class is not doing anything and I dont know how to store the $id that comes from mysql into my class.
Thanks in advance
I'm trying to retrieve information from Mysql using mysql_fetch_object and store each row as an object.
I know that I can use something like this, but is not stored in my class
while ($row = mysql_fetch_object($result))
{
echo $row->id;
}
I need to store the fields in a class to make some changes in the values.
class className{
var $newId;
function className()
{
$this->newId = $id + 100;
}
}
while ($row = mysql_fetch_object($result, "className"))
{
echo $row->newId;
}
The thing is that the constructor of the class is not doing anything and I dont know how to store the $id that comes from mysql into my class.
Thanks in advance