本文整理汇总了PHP中app\models\Student::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::toArray方法的具体用法?PHP Student::toArray怎么用?PHP Student::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Student
的用法示例。
在下文中一共展示了Student::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['Application'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Application'][$this->hashCode()] = true;
$keys = ApplicationTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getStudentId(), $keys[2] => $this->getSubjectId(), $keys[3] => $this->getPeriodId(), $keys[4] => $this->getSchoolYearId(), $keys[5] => $this->getApplicationDate(), $keys[6] => $this->getExamDate(), $keys[7] => $this->getExamTime(), $keys[8] => $this->getExamScore(), $keys[9] => $this->getCreatedAt(), $keys[10] => $this->getUpdatedAt());
$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');
}
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->aPeriod) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'period';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'period';
break;
default:
$key = 'Period';
}
$result[$key] = $this->aPeriod->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->aStudent) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'student';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'student';
break;
default:
$key = 'Student';
}
$result[$key] = $this->aStudent->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';
//.........这里部分代码省略.........
示例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['AdminUser'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['AdminUser'][$this->hashCode()] = true;
$keys = AdminUserTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getLanguageId(), $keys[2] => $this->getProfessorId(), $keys[3] => $this->getStudentId(), $keys[4] => $this->getName(), $keys[5] => $this->getLogin(), $keys[6] => $this->getPassword(), $keys[7] => $this->getEmail(), $keys[8] => $this->getStatus(), $keys[9] => $this->getRememberToken(), $keys[10] => $this->getCreatedAt(), $keys[11] => $this->getUpdatedAt());
$utc = new \DateTimeZone('utc');
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');
}
if ($result[$keys[11]] instanceof \DateTime) {
// When changing timezone we don't want to change existing instances
$dateTime = clone $result[$keys[11]];
$result[$keys[11]] = $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->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->aStudent) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'student';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'student';
break;
default:
$key = 'Student';
}
$result[$key] = $this->aStudent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aTranslationLanguage) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'translationLanguage';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'translation_language';
break;
default:
$key = 'TranslationLanguage';
}
$result[$key] = $this->aTranslationLanguage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collAdminUserCredentials) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'adminUserCredentials';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'admin_user_credentials';
break;
default:
$key = 'AdminUserCredentials';
}
$result[$key] = $this->collAdminUserCredentials->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
}