本文整理汇总了PHP中Tag::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::toArray方法的具体用法?PHP Tag::toArray怎么用?PHP Tag::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::toArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* Defaults to BasePeer::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 = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['TagInstance'][serialize($this->getPrimaryKey())])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['TagInstance'][serialize($this->getPrimaryKey())] = true;
$keys = TagInstancePeer::getFieldNames($keyType);
$result = array($keys[0] => $this->getTagId(), $keys[1] => $this->getTaggedItemId(), $keys[2] => $this->getModelName(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), $keys[5] => $this->getCreatedBy(), $keys[6] => $this->getUpdatedBy());
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aTag) {
$result['Tag'] = $this->aTag->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aUserRelatedByCreatedBy) {
$result['UserRelatedByCreatedBy'] = $this->aUserRelatedByCreatedBy->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aUserRelatedByUpdatedBy) {
$result['UserRelatedByUpdatedBy'] = $this->aUserRelatedByUpdatedBy->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), array('name' => 'required'));
if ($validator->fails()) {
return Response::json($validator->messages(), 400);
}
$tag = new Tag();
$tag->name = Input::get('name');
$tag->description = Input::get('description');
$tag->save();
return Response::json(array('success_code' => 'OK', 'data' => $tag->toArray()), 200);
}
示例3: tagData
public function tagData()
{
$oTag = TagQuery::create()->findPk($this->iTagId);
if ($oTag === null) {
$oTag = new Tag();
}
$aResult = $oTag->toArray();
$aResult['CreatedInfo'] = Util::formatCreatedInfo($oTag);
$aResult['UpdatedInfo'] = Util::formatUpdatedInfo($oTag);
$aResult['tagged_models_and_items'] = array();
foreach ($oTag->getTagInstances() as $oTagInstance) {
$oCorrObject = $oTagInstance->getCorrespondingDataEntry();
if ($oCorrObject) {
$aResult['tagged_models_and_items'][] = array('name' => Util::nameForObject($oCorrObject), 'tagged_item_id' => $oTagInstance->getTaggedItemId(), 'model_name' => $oTagInstance->getModelName());
} else {
$oTagInstance->delete();
}
}
return $aResult;
}
示例4: Tag
<?php
# Include autoloader
require_once 'vendor/autoload.php';
# Include config
require_once 'generated-conf/config.php';
$verse = find_verse('Genesis 1:4');
$keyword = find_keyword('Jealousy');
$type = find_tag_type('instructs regarding');
$tag = new Tag();
$tag->setKeyword($keyword)->setTagType($type)->setVerse($verse)->save();
var_dump($tag->toArray());
示例5: diff
public function diff(Tag $tag, $matchSortOrder = false)
{
$diffArray = array();
$tagArray = $tag->toArray();
$matchArray = array('TagElement', 'TagSlug', 'TagRole', 'TagValue', 'TagValueDisplay');
if ($matchSortOrder) {
$matchArray[] = 'TagSortOrder';
}
foreach ($matchArray as $key) {
// error_log('COMPARE ['.$key.'] val1 = ['.$tagArray[$key].'] with val2 = ['.$this->fields[$key].']');
if ((string) $tagArray[$key] !== (string) $this->fields[$key]) {
// error_log('Unmatched key: '.$key);
$diffArray[] = $key;
}
}
return $diffArray;
}