本文整理匯總了PHP中models\User::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::toArray方法的具體用法?PHP User::toArray怎麽用?PHP User::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::toArray方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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['UserGroup'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['UserGroup'][$this->hashCode()] = true;
$keys = UserGroupTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getUserId(), $keys[1] => $this->getGroupId(), $keys[2] => $this->getRights());
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'user';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'user';
break;
default:
$key = 'User';
}
$result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aGroup) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'group';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'group';
break;
default:
$key = 'Group';
}
$result[$key] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
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['Group'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Group'][$this->hashCode()] = true;
$keys = GroupTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getName(), $keys[2] => $this->getDescription(), $keys[3] => $this->getOwnerId(), $keys[4] => $this->getCreatedAt(), $keys[5] => $this->getUpdatedAt());
if ($result[$keys[4]] instanceof \DateTime) {
$result[$keys[4]] = $result[$keys[4]]->format('c');
}
if ($result[$keys[5]] instanceof \DateTime) {
$result[$keys[5]] = $result[$keys[5]]->format('c');
}
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aOwner) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'user';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'user';
break;
default:
$key = 'User';
}
$result[$key] = $this->aOwner->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collPackPermissions) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'packPermissions';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'pack_permissions';
break;
default:
$key = 'PackPermissions';
}
$result[$key] = $this->collPackPermissions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collUserGroups) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'userGroups';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'user_groups';
break;
default:
$key = 'UserGroups';
}
$result[$key] = $this->collUserGroups->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
}
示例3: 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['Comment'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Comment'][$this->hashCode()] = true;
$keys = CommentTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getUserId(), $keys[2] => $this->getNoteId(), $keys[3] => $this->getText(), $keys[4] => $this->getCreatedAt(), $keys[5] => $this->getUpdatedAt());
if ($result[$keys[4]] instanceof \DateTime) {
$result[$keys[4]] = $result[$keys[4]]->format('c');
}
if ($result[$keys[5]] instanceof \DateTime) {
$result[$keys[5]] = $result[$keys[5]]->format('c');
}
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'user';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'user';
break;
default:
$key = 'User';
}
$result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aNote) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'note';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'note';
break;
default:
$key = 'Note';
}
$result[$key] = $this->aNote->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
}
示例4: 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['Note'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Note'][$this->hashCode()] = true;
$keys = NoteTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getUserId(), $keys[2] => $this->getImportance(), $keys[3] => $this->getTitle(), $keys[4] => $this->getDeadline(), $keys[5] => $this->getCategoryId(), $keys[6] => $this->getState(), $keys[7] => $this->getRepeatAfter(), $keys[8] => $this->getDoneAt(), $keys[9] => $this->getPublic(), $keys[10] => $this->getDescription(), $keys[11] => $this->getCreatedAt(), $keys[12] => $this->getUpdatedAt());
if ($result[$keys[4]] instanceof \DateTime) {
$result[$keys[4]] = $result[$keys[4]]->format('c');
}
if ($result[$keys[8]] instanceof \DateTime) {
$result[$keys[8]] = $result[$keys[8]]->format('c');
}
if ($result[$keys[11]] instanceof \DateTime) {
$result[$keys[11]] = $result[$keys[11]]->format('c');
}
if ($result[$keys[12]] instanceof \DateTime) {
$result[$keys[12]] = $result[$keys[12]]->format('c');
}
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'user';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'user';
break;
default:
$key = 'User';
}
$result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCategory) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'category';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'category';
break;
default:
$key = 'Category';
}
$result[$key] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collSubNotes) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'subNotes';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'sub_notes';
break;
default:
$key = 'SubNotes';
}
$result[$key] = $this->collSubNotes->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collFiles) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'files';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'files';
break;
default:
$key = 'Files';
}
$result[$key] = $this->collFiles->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
if (null !== $this->collNotifications) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'notifications';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'notifications';
break;
//.........這裏部分代碼省略.........
示例5: toArray
public function toArray()
{
$this->_load();
return parent::toArray();
}
示例6: 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['Article'][$this->hashCode()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Article'][$this->hashCode()] = true;
$keys = ArticleTableMap::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getIdUser(), $keys[2] => $this->getIdImage(), $keys[3] => $this->getIdCategory(), $keys[4] => $this->getTitle(), $keys[5] => $this->getUrl(), $keys[6] => $this->getKeywords(), $keys[7] => $this->getContent(), $keys[8] => $this->getCreatedAt(), $keys[9] => $this->getUpdatedAt());
if ($result[$keys[8]] instanceof \DateTime) {
$result[$keys[8]] = $result[$keys[8]]->format('c');
}
if ($result[$keys[9]] instanceof \DateTime) {
$result[$keys[9]] = $result[$keys[9]]->format('c');
}
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'user';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'users';
break;
default:
$key = 'User';
}
$result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aImage) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'image';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'images';
break;
default:
$key = 'Image';
}
$result[$key] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCategory) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'category';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'categories';
break;
default:
$key = 'Category';
}
$result[$key] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->collComments) {
switch ($keyType) {
case TableMap::TYPE_CAMELNAME:
$key = 'comments';
break;
case TableMap::TYPE_FIELDNAME:
$key = 'commentss';
break;
default:
$key = 'Comments';
}
$result[$key] = $this->collComments->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
}