All pastes #386023 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-08 08:38 UTC
rendered paste body
==== Return from a method ====
array(1) {
  [0]=>
  object(attributes_itmlabelmodel)(11) {
    ["attributes"]=>
    NULL
    ["errorcode"]=>
    NULL
    ["classname"]=>
    NULL
    ["errormessage"]=>
    NULL
    ["log"]=>
    NULL
    ["associates"]=>
    array(0) {
    }
    ["saveCallbacks"]=>
    NULL
    ["id"]=>
    string(2) "31"
    ["name"]=>
    string(14) "trustthedj.com"
    ["active"]=>
    string(1) "0"
    ["owner"]=>
    string(1) "2"
  }
}

==== I run list($var) on the above return and then I var_dump($var) =====
object(attributes_itmlabelmodel)(11) {
  ["attributes"]=>
  NULL
  ["errorcode"]=>
  NULL
  ["classname"]=>
  NULL
  ["errormessage"]=>
  NULL
  ["log"]=>
  NULL
  ["associates"]=>
  array(0) {
  }
  ["saveCallbacks"]=>
  NULL
  ["id"]=>
  string(2) "31"
  ["name"]=>
  string(14) "trustthedj.com"
  ["active"]=>
  string(1) "0"
  ["owner"]=>
  string(1) "2"
}

bool(false)

=========================================
I get a bool false! WTF! 

=========================================
The method which returns the value for $var
function CreateObjectsFromResultSet(& $result, $useIdAsKey=false, $sql = false, $db = false)
	{
		$ret = false;
		if (!is_object($result)){
			trigger_error("comments: BAD SQL! - ".$sql." - ".$db->ErrorMsg(), E_USER_ERROR);
			return false;
		}
		while ($row = $result->fetchRow()) {
			$item = new Attributes_ItmLabelModel($row);
			if (is_object($this) && $this->associates){
				foreach ($this->associates as $associate){
					$primaryKeyGetter = 'get' . $associate['primaryKeyName'];
					$associateObjectArray = $associate['object']->RetrieveByColumnName($associate['foreignColumnName'], $item->$primaryKeyGetter());
					
					if ($associateObjectArray){
						foreach ( $associateObjectArray as $associateObject ){
							$item->addAssociate($associateObject, $associate['foreignKeyName'],  $associate['primaryKeyName']);
						}
					}
				}  
			}
			if ($useIdAsKey){
                        
				$id = $row['id'];
                        
				$ret[$id]= $item;
			} else {
				$ret[]= $item;
			}
		}
		return $ret;
	}

=======================================
if I set $ret at the stat of the method to be array(), the extra bool(false) I get from the list changes to an empty array. Huh?!
What is list() doing?