Esempio n. 1
0
 /**
  * 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['Players'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Players'][$this->hashCode()] = true;
     $keys = PlayersTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getLastn(), $keys[2] => $this->getBats(), $keys[3] => $this->getBday(), $keys[4] => $this->getAge(), $keys[5] => $this->getMlb(), $keys[6] => $this->getDraftYear(), $keys[7] => $this->getPosition(), $keys[8] => $this->getCard(), $keys[9] => $this->getDE(), $keys[10] => $this->getLg(), $keys[11] => $this->getMwbl(), $keys[12] => $this->getCategory(), $keys[13] => $this->getComment(), $keys[14] => $this->getMwblLink(), $keys[15] => $this->getMlbLink(), $keys[16] => $this->getMwblLinkEnabled(), $keys[17] => $this->getMlbLinkEnabled(), $keys[18] => $this->getCreateTs(), $keys[19] => $this->getMaintTs());
     $utc = new \DateTimeZone('utc');
     if ($result[$keys[3]] instanceof \DateTime) {
         // When changing timezone we don't want to change existing instances
         $dateTime = clone $result[$keys[3]];
         $result[$keys[3]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z');
     }
     if ($result[$keys[18]] instanceof \DateTime) {
         // When changing timezone we don't want to change existing instances
         $dateTime = clone $result[$keys[18]];
         $result[$keys[18]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z');
     }
     if ($result[$keys[19]] instanceof \DateTime) {
         // When changing timezone we don't want to change existing instances
         $dateTime = clone $result[$keys[19]];
         $result[$keys[19]] = $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->aMlbTeamRef) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'mlbTeamRef';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'mlb_team_ref';
                     break;
                 default:
                     $key = 'MlbTeamRef';
             }
             $result[$key] = $this->aMlbTeamRef->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aCardRef) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'cardRef';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'card_ref';
                     break;
                 default:
                     $key = 'CardRef';
             }
             $result[$key] = $this->aCardRef->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aDivisionRef) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'divisionRef';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'division_ref';
                     break;
                 default:
                     $key = 'DivisionRef';
             }
             $result[$key] = $this->aDivisionRef->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aPositionRef) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'positionRef';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'position_ref';
                     break;
                 default:
                     $key = 'PositionRef';
             }
             $result[$key] = $this->aPositionRef->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aTeams) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'teams';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'Teams';
                     break;
                 default:
                     $key = 'Teams';
             }
             $result[$key] = $this->aTeams->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * 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['Teams'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Teams'][$this->hashCode()] = true;
     $keys = TeamsTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getLink(), $keys[2] => $this->getOwner(), $keys[3] => $this->getName(), $keys[4] => $this->getNickname(), $keys[5] => $this->getTeamAbbrev(), $keys[6] => $this->getDivision(), $keys[7] => $this->getEmail(), $keys[8] => $this->getStatus(), $keys[9] => $this->getComment(), $keys[10] => $this->getLeague(), $keys[11] => $this->getUsed(), $keys[12] => $this->getEmail2(), $keys[13] => $this->getAddress(), $keys[14] => $this->getCity(), $keys[15] => $this->getState(), $keys[16] => $this->getZip(), $keys[17] => $this->getPhone(), $keys[18] => $this->getTeamLink(), $keys[19] => $this->getTradeLink(), $keys[20] => $this->getDraftLink(), $keys[21] => $this->getAwardsLink(), $keys[22] => $this->getAim(), $keys[23] => $this->getYahoo(), $keys[24] => $this->getCreateTs(), $keys[25] => $this->getMaintTs());
     $utc = new \DateTimeZone('utc');
     if ($result[$keys[24]] instanceof \DateTime) {
         // When changing timezone we don't want to change existing instances
         $dateTime = clone $result[$keys[24]];
         $result[$keys[24]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z');
     }
     if ($result[$keys[25]] instanceof \DateTime) {
         // When changing timezone we don't want to change existing instances
         $dateTime = clone $result[$keys[25]];
         $result[$keys[25]] = $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->aDivisionRef) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'divisionRef';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'division_ref';
                     break;
                 default:
                     $key = 'DivisionRef';
             }
             $result[$key] = $this->aDivisionRef->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aLeagueRef) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'leagueRef';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'league_ref';
                     break;
                 default:
                     $key = 'LeagueRef';
             }
             $result[$key] = $this->aLeagueRef->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collPlayerss) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'playerss';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'playerss';
                     break;
                 default:
                     $key = 'Playerss';
             }
             $result[$key] = $this->collPlayerss->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }