/** * 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['Project'][$this->hashCode()])) { return '*RECURSION*'; } $alreadyDumpedObjects['Project'][$this->hashCode()] = true; $keys = ProjectTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getName(), $keys[2] => $this->getLimit(), $keys[3] => $this->getRate(), $keys[4] => $this->getEmployeeId(), $keys[5] => $this->getCustomerId()); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aCustomer) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'customer'; break; case TableMap::TYPE_FIELDNAME: $key = 'customer'; break; default: $key = 'Customer'; } $result[$key] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aEmployee) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'employee'; break; case TableMap::TYPE_FIELDNAME: $key = 'employee'; break; default: $key = 'Employee'; } $result[$key] = $this->aEmployee->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->collTasks) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'tasks'; break; case TableMap::TYPE_FIELDNAME: $key = 'tasks'; break; default: $key = 'Tasks'; } $result[$key] = $this->collTasks->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } 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['Task'][$this->hashCode()])) { return '*RECURSION*'; } $alreadyDumpedObjects['Task'][$this->hashCode()] = true; $keys = TaskTableMap::getFieldNames($keyType); $result = array($keys[0] => $this->getId(), $keys[1] => $this->getTitle(), $keys[2] => $this->getDescription(), $keys[3] => $this->getWorktime(), $keys[4] => $this->getProjectId(), $keys[5] => $this->getEmployeeId()); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->aEmployee) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'employee'; break; case TableMap::TYPE_FIELDNAME: $key = 'employee'; break; default: $key = 'Employee'; } $result[$key] = $this->aEmployee->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->aProject) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'project'; break; case TableMap::TYPE_FIELDNAME: $key = 'project'; break; default: $key = 'Project'; } $result[$key] = $this->aProject->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } if (null !== $this->collBills) { switch ($keyType) { case TableMap::TYPE_CAMELNAME: $key = 'bills'; break; case TableMap::TYPE_FIELDNAME: $key = 'bills'; break; default: $key = 'Bills'; } $result[$key] = $this->collBills->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } return $result; }