本文整理汇总了PHP中BaseObject::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseObject::getPrimaryKey方法的具体用法?PHP BaseObject::getPrimaryKey怎么用?PHP BaseObject::getPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject::getPrimaryKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteByObject
public static function deleteByObject(BaseObject $object)
{
$c = new Criteria();
$c->add(sfApprovalPeer::APPROVABLE_ID, $object->getPrimaryKey());
$c->add(sfApprovalPeer::APPROVABLE_MODEL, get_class($object));
$approval = sfApprovalPeer::doDelete($c);
}
示例2: populateFromObject
/**
* Populates version properties and creates necessary entries in the resource_attribute_version table.
*
* @param BaseObject $resource
* @param Array $withObjects Optional list of object classes to create and attach to the current resource
*/
public function populateFromObject(BaseObject $resource, $withObjects = array(), $withVersion = true)
{
$this->setResourceId($resource->getPrimaryKey());
$this->setResourceName(get_class($resource));
if ($withVersion) {
$this->setNumber($resource->getVersion());
}
foreach ($resource->getPeer()->getFieldNames() as $attribute_name) {
$getter = sprintf('get%s', $attribute_name);
$attribute_version = new ResourceAttributeVersion();
$attribute_version->setAttributeName($attribute_name);
$attribute_version->setAttributeValue($resource->{$getter}());
$this->addResourceAttributeVersion($attribute_version);
}
foreach ($withObjects as $resourceName) {
$getter = sprintf('get%s', $resourceName);
$relatedResources = $resource->{$getter}();
if (!is_array($relatedResources)) {
$relatedResources = array($relatedResources);
}
foreach ($relatedResources as $relatedResource) {
$resourceVersion = new ResourceVersion();
$resourceVersion->populateFromObject($relatedResource, array(), false);
$this->addResourceVersionRelatedByResourceVersionId($resourceVersion);
}
}
}
示例3: objectToJson
/**
* Get node properties from propel object.
*
* @param mixed|\BaseObject $instance
* @param Tree $tree
* @param int $depth
* @return array
*/
public function objectToJson($instance, Tree $tree, $depth = 0)
{
$p = array('title' => (string) $instance, 'key' => (string) $instance->getPrimaryKey());
if ($instance->hasChildren()) {
$p['children'] = array();
if ($this->lazy) {
$p['isLazy'] = true;
}
}
return $p;
}
示例4: processPostData
/**
* Process post data
*
* @return boolean
* @author Łukasz Wojciechowski
* @author Radu Topala <radu@appflower.com>
*/
public function processPostData()
{
$formData = $this->getRequest()->getParameter('edit');
$formData = isset($formData[0]) ? $formData[0] : array();
$this->processCheckboxes($formData);
$this->changeKeysForForeignFields($formData);
// filtered means that we are leaving only values for fields that exists in the form
$formDataFiltered = array();
foreach ($this->getFieldNamesOfForm($this->form) as $fieldName) {
if (isset($formData[$fieldName])) {
$formDataFiltered[$fieldName] = $formData[$fieldName];
}
}
$this->form->bind($formDataFiltered);
$formSave = $this->form->save();
//set object after saving and add double multi-combo values after adding main object, if doesn't exist
$this->object = $this->form->getObject();
$this->id = $this->object->getPrimaryKey();
$this->processMultipleRelations($formData);
return $formSave;
}
示例5: getSavedTags
/**
* Retrieves from the database tags that have been atached to the object.
* Once loaded, this saved tags list is cached and updated in memory.
*
* @param BaseObject $object
*/
private function getSavedTags(BaseObject $object)
{
if (!isset($object->_tags) || !$object->_tags->hasNamespace('saved_tags')) {
$c = new Criteria();
$c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey());
$c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object));
$c->addJoin(TaggingPeer::TAG_ID, TagPeer::ID);
$saved_tags = TagPeer::doSelect($c);
$tags = array();
foreach ($saved_tags as $tag) {
$tags[$tag->getName()] = $tag->getName();
}
self::set_saved_tags($object, $tags);
return $tags;
} else {
return self::get_saved_tags($object);
}
}
示例6: reload
/**
* Returns an up to date version of node.
*
* @param BaseObject $node
* @return BaseObject
*/
public function reload(BaseObject $node)
{
return call_user_func(array($node->getPeer(), 'retrieveByPk'), $node->getPrimaryKey());
}
示例7: removeComment
/**
* Removes one comment from the object.
*
* @param BaseObject $object
*/
public function removeComment(BaseObject $object, $comment_id)
{
$c = new Criteria();
$c->add(sfCommentPeer::COMMENTABLE_ID, $object->getPrimaryKey());
$c->add(sfCommentPeer::COMMENTABLE_MODEL, get_class($object));
$c->add(sfCommentPeer::ID, $comment_id);
return sfCommentPeer::doDelete($c);
}
示例8: getObjectPk
/**
* Get primary-key of object as string.
*
* @param BaseObject $obj
* @return string
*/
public static function getObjectPk(BaseObject $obj)
{
return json_encode($obj->getPrimaryKey());
}
示例9: userRecommendationExists
/**
* Tells if a given user has already recommended the object
*
* @param BaseObject $object
* @param integer $user_id
* @return bool
**/
public function userRecommendationExists(BaseObject $object, $user_id)
{
$c = new Criteria();
$c->add(sfUserRecommendationPeer::RECOMMENDABLE_ID, $object->getPrimaryKey());
$c->add(sfUserRecommendationPeer::RECOMMENDABLE_MODEL, get_class($object));
$c->add(sfUserRecommendationPeer::USER_ID, $user_id);
$result = sfUserRecommendationPeer::doSelectOne($c);
return is_null($result) ? false : true;
}
示例10: getUserSavedTags
/**
* Retrieves from the database tags that have been attached to the object by a user
* If the user_id parameter is not passed, then retrieve all tags attached by the users (user_id is not null)
*
* @param BaseObject $object
* @param integer $user_id
*/
private function getUserSavedTags(BaseObject $object, $user_id = null)
{
$c = new Criteria();
$c->add(TaggingPeer::TAGGABLE_ID, $object->getPrimaryKey());
$c->add(TaggingPeer::TAGGABLE_MODEL, get_class($object));
$c->addJoin(TaggingPeer::TAG_ID, TagPeer::ID);
if (!is_null($user_id) && $user_id != '') {
$c->add(TaggingPeer::USER_ID, $user_id);
} else {
$c->add(TaggingPeer::USER_ID, null, Criteria::ISNOTNULL);
}
$saved_tags = TagPeer::doSelect($c);
$tags = array();
foreach ($saved_tags as $tag) {
$tags[$tag->getName()] = $tag->getName();
}
return $tags;
}
示例11: preDelete
/**
* Delete all launching for a launchable object (delete cascade emulation)
*
* @param BaseObject $object
*/
public function preDelete(BaseObject $object)
{
try {
$c = new Criteria();
$c->add(sfLaunchingPeer::OBJECT_ID, $object->getPrimaryKey());
$ls = sfLaunchingPeer::doSelect($c);
foreach ($ls as $l) {
$l->delete();
}
sfLaunchingPeer::resetPriorities();
} catch (Exception $e) {
throw new deppPropelActAsLaunchableException('Unable to delete launchable object\'s related launchings records');
}
}
示例12: saveCounter
/**
* Saves the counter into the database.
*
* @param BaseObject $object
*/
public function saveCounter(BaseObject $object)
{
if (isset($object->_counter) && isset($object->_forced) && $object->_forced) {
$c = new Criteria();
$c->add(sfCounterPeer::COUNTABLE_ID, $object->getPrimaryKey());
$c->add(sfCounterPeer::COUNTABLE_MODEL, get_class($object));
$counter = sfCounterPeer::doSelectOne($c);
if (is_null($counter)) {
$counter = $object->_counter;
} else {
$counter->setCounter($object->_counter->getCounter());
}
$object->_counter = $counter;
$object->_forced = false;
}
$object->_counter->save();
}
示例13: postDelete
/**
* This hook is called just after a resource is deleted and takes care of deleting its version history.
*/
public function postDelete(BaseObject $resource)
{
$c = new Criteria();
$c->add(ResourceVersionPeer::RESOURCE_ID, $resource->getPrimaryKey());
$c->add(ResourceVersionPeer::RESOURCE_NAME, get_class($resource));
ResourceVersionPeer::doDelete($c);
}
示例14: preDelete
/**
* Deletes all comments for a commentable object (on delete cascade emulation)
*
* @param BaseObject $object
*/
public function preDelete(BaseObject $object)
{
try {
$c = new Criteria();
$c->add(sfCommentPeer::COMMENTABLE_ID, $object->getPrimaryKey());
sfCommentPeer::doDelete($c);
} catch (Exception $e) {
throw new Exception('Unable to delete comments related to commentable object');
}
}
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:15,代码来源:deppPropelActAsCommentableBehavior.class.php
示例15: setObject
/**
* @param BaseObject $object
*/
public function setObject(BaseObject $object)
{
$this->peer = get_class($object->getPeer());
$this->primaryKey = $object->getPrimaryKey();
}