/** * Exports the object as an array. * * You can specify the key type of the array by passing one of the class * type constants. * * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. * Defaults to TableMap::TYPE_PHPNAME. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. * * @return array an associative array containing the field names (as keys) and field values */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['RigAttributeValues'][$this->hashCode()])) { return '*RECURSION*'; } $alreadyDumpedObjects['RigAttributeValues'][$this->hashCode()] = true; $keys = RigAttributeValuesTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getRigId(), $keys[2] => $this->getRigAttributeId(), $keys[3] => $this->getValue()); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aRigs) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'rigs'; break; case TableMap::TYPE_FIELDNAME: $key = 'rigs'; break; default: $key = 'Rigs'; } $result[$key] = $this->aRigs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aRigAttributes) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'rigAttributes'; break; case TableMap::TYPE_FIELDNAME: $key = 'rig_attributes'; break; default: $key = 'RigAttributes'; } $result[$key] = $this->aRigAttributes->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } } return $result; }
/** * Exports the object as an array. * * You can specify the key type of the array by passing one of the class * type constants. * * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. * Defaults to TableMap::TYPE_PHPNAME. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. * * @return array an associative array containing the field names (as keys) and field values */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['RatingHeaders'][$this->hashCode()])) { return '*RECURSION*'; } $alreadyDumpedObjects['RatingHeaders'][$this->hashCode()] = true; $keys = RatingHeadersTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getGameId(), $keys[2] => $this->getUserId(), $keys[3] => $this->getGamePlatformId(), $keys[4] => $this->getRigId(), $keys[5] => $this->getCreated(), $keys[6] => $this->getUpdated(), $keys[7] => $this->getUpvotes(), $keys[8] => $this->getDownvotes(), $keys[9] => $this->getComments(), $keys[10] => $this->getScore()); $utc = new \DateTimeZone('utc'); if ($result[$keys[5]] instanceof \DateTime) { // When changing timezone we don't want to change existing instances $dateTime = clone $result[$keys[5]]; $result[$keys[5]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z'); } if ($result[$keys[6]] instanceof \DateTime) { // When changing timezone we don't want to change existing instances $dateTime = clone $result[$keys[6]]; $result[$keys[6]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z'); } $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aGames) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'games'; break; case TableMap::TYPE_FIELDNAME: $key = 'games'; break; default: $key = 'Games'; } $result[$key] = $this->aGames->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aUser) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'user'; break; case TableMap::TYPE_FIELDNAME: $key = 'user'; break; default: $key = 'User'; } $result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aRigs) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'rigs'; break; case TableMap::TYPE_FIELDNAME: $key = 'rigs'; break; default: $key = 'Rigs'; } $result[$key] = $this->aRigs->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aPlatforms) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'platforms'; break; case TableMap::TYPE_FIELDNAME: $key = 'platforms'; break; default: $key = 'Platforms'; } $result[$key] = $this->aPlatforms->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->collRatingCategoryValuess) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'ratingCategoryValuess'; break; case TableMap::TYPE_FIELDNAME: $key = 'rating_category_valuess'; break; default: $key = 'RatingCategoryValuess'; } $result[$key] = $this->collRatingCategoryValuess->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } return $result; }