Welcome Guest, Not a member yet? Register   Sign In
Looking for an explanation of stdClass Object
#2

[eluser]mddd[/eluser]
1. StdClass means an object that has no specific class. It is "just a basic object". Every object in php start out from a 'basic object' which is then extended with all the characteristics of the specific class that it is an instance of (like Model, Controller, etc).

2. A mysql result is simply a list of objects. Each object is one row from the database result. If you wanted to display all the names, you would do:
Code:
foreach ($list as $item)
{
  echo 'name: ' . $item->name;
}
If you feel more comfortable with arrays, you can always use result_array() instead of result(). That will give a list of arrays instead of a list of objects. Then you could do:
Code:
foreach ($list as $item)
{
  echo 'name: ' . $item['name'];
}


Messages In This Thread
Looking for an explanation of stdClass Object - by El Forum - 06-25-2010, 02:29 AM
Looking for an explanation of stdClass Object - by El Forum - 06-25-2010, 02:58 AM
Looking for an explanation of stdClass Object - by El Forum - 06-25-2010, 03:09 AM
Looking for an explanation of stdClass Object - by El Forum - 06-25-2010, 03:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB