本文整理汇总了PHP中app\models\Course::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::toArray方法的具体用法?PHP Course::toArray怎么用?PHP Course::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toArray
/**
* 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['Student'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Student'][$this->hashCode()] = true;
$keys = StudentTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getIdentificationNumber(), $keys[2] => $this->getSchoolYearId(), $keys[3] => $this->getCourseId(), $keys[4] => $this->getFirstName(), $keys[5] => $this->getLastName(), $keys[6] => $this->getBirthPlace(), $keys[7] => $this->getBirthday(), $keys[8] => $this->getPhoneNumber(), $keys[9] => $this->getCreatedAt(), $keys[10] => $this->getUpdatedAt());
$utc = new \DateTimeZone('utc');
if ($result[$keys[7]] instanceof \DateTime) {
// When changing timezone we don't want to change existing instances
$dateTime = clone $result[$keys[7]];
$result[$keys[7]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z');
}
if ($result[$keys[9]] instanceof \DateTime) {
// When changing timezone we don't want to change existing instances
$dateTime = clone $result[$keys[9]];
$result[$keys[9]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z');
}
if ($result[$keys[10]] instanceof \DateTime) {
// When changing timezone we don't want to change existing instances
$dateTime = clone $result[$keys[10]];
$result[$keys[10]] = $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->aCourse) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'course';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'course';
break;
default:
$key = 'Course';
}
$result[$key] = $this->aCourse->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aSchoolYear) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'schoolYear';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'school_year';
break;
default:
$key = 'SchoolYear';
}
$result[$key] = $this->aSchoolYear->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collAdminUsers) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'adminUsers';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'admin_users';
break;
default:
$key = 'AdminUsers';
}
$result[$key] = $this->collAdminUsers->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collApplications) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'applications';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'applications';
break;
default:
$key = 'Applications';
}
$result[$key] = $this->collApplications->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
}
示例2: toArray
/**
* 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['Engagement'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Engagement'][$this->hashCode()] = true;
$keys = EngagementTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getProfessorId(), $keys[1] => $this->getSubjectId(), $keys[2] => $this->getCourseId(), $keys[3] => $this->getSchoolYearId(), $keys[4] => $this->getCreatedAt(), $keys[5] => $this->getUpdatedAt());
$utc = new \DateTimeZone('utc');
if ($result[$keys[4]] instanceof \DateTime) {
// When changing timezone we don't want to change existing instances
$dateTime = clone $result[$keys[4]];
$result[$keys[4]] = $dateTime->setTimezone($utc)->format('Y-m-d\\TH:i:s\\Z');
}
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');
}
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aCourse) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'course';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'course';
break;
default:
$key = 'Course';
}
$result[$key] = $this->aCourse->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aProfessor) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'professor';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'professor';
break;
default:
$key = 'Professor';
}
$result[$key] = $this->aProfessor->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aSubject) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'subject';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'subject';
break;
default:
$key = 'Subject';
}
$result[$key] = $this->aSubject->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aSchoolYear) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'schoolYear';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'school_year';
break;
default:
$key = 'SchoolYear';
}
$result[$key] = $this->aSchoolYear->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
}