/** * 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['Subdivision'][$this->hashCode()])) { return '*RECURSION*'; } $alreadyDumpedObjects['Subdivision'][$this->hashCode()] = true; $keys = SubdivisionTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getCode(), $keys[2] => $this->getName(), $keys[3] => $this->getNativeName(), $keys[4] => $this->getAltNames(), $keys[5] => $this->getParentId(), $keys[6] => $this->getCountryId(), $keys[7] => $this->getTypeId()); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aCountry) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'country'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_country'; break; default: $key = 'Country'; } $result[$key] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aType) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'regionType'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_region_type'; break; default: $key = 'RegionType'; } $result[$key] = $this->aType->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['Country'][$this->hashCode()])) { return '*RECURSION*'; } $alreadyDumpedObjects['Country'][$this->hashCode()] = true; $keys = CountryTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getNumeric(), $keys[2] => $this->getAlpha2(), $keys[3] => $this->getAlpha3(), $keys[4] => $this->getShortName(), $keys[5] => $this->getIoc(), $keys[6] => $this->getTld(), $keys[7] => $this->getPhone(), $keys[8] => $this->getCapital(), $keys[9] => $this->getPostalCodeFormat(), $keys[10] => $this->getPostalCodeRegex(), $keys[11] => $this->getContinentId(), $keys[12] => $this->getCurrencyId(), $keys[13] => $this->getTypeId(), $keys[14] => $this->getSubtypeId(), $keys[15] => $this->getSovereignityId(), $keys[16] => $this->getFormalName(), $keys[17] => $this->getFormalNativeName(), $keys[18] => $this->getShortNativeName(), $keys[19] => $this->getBboxSwLat(), $keys[20] => $this->getBboxSwLng(), $keys[21] => $this->getBboxNeLat(), $keys[22] => $this->getBboxNeLng()); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aContinent) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'continent'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_continent'; break; default: $key = 'Continent'; } $result[$key] = $this->aContinent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aCurrency) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'currency'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_currency'; break; default: $key = 'Currency'; } $result[$key] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aType) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'regionType'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_region_type'; break; default: $key = 'RegionType'; } $result[$key] = $this->aType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aSubtype) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'regionType'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_region_type'; break; default: $key = 'RegionType'; } $result[$key] = $this->aSubtype->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aCountryRelatedBySovereignityId) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'country'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_country'; break; default: $key = 'Country'; } $result[$key] = $this->aCountryRelatedBySovereignityId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->collSubordinates) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'countries'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_countries'; break; default: $key = 'Countries'; } $result[$key] = $this->collSubordinates->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collSubdivisions) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'subdivisions'; break; case TableMap::TYPE_FIELDNAME: $key = 'kk_subdivisions'; break; default: $key = 'Subdivisions'; } $result[$key] = $this->collSubdivisions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } return $result; }