本文整理汇总了PHP中Objects::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Objects::findById方法的具体用法?PHP Objects::findById怎么用?PHP Objects::findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::findById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findById
function findById($id, $force_reload = false)
{
$co = parent::findById($id, $force_reload);
if (!is_null($co)) {
$co->setObject(Objects::findById($id, $force_reload));
}
return $co;
}
示例2: delete
function delete($check = true) {
if ($check && !$this->canBeDeleted($error_message)) {
throw new Exception($error_message);
}
// change parent of child nodes
$child_members = $this->getAllChildren();
if (is_array($child_members)) {
$parent = $this->getParentMember();
foreach($child_members as $child) {
$child->setParentMemberId($this->getParentMemberId());
if ($parent instanceof Member) {
$child->setDepth($parent->getDepth()+1);
} else $child->setDepth(1);
$child->save();
}
}
// delete member restrictions
MemberRestrictions::delete(array("`member_id` = ?", $this->getId()));
MemberRestrictions::delete(array("`restricted_member_id` = ?", $this->getId()));
// delete member properties
MemberPropertyMembers::delete(array("`member_id` = ?", $this->getId()));
MemberPropertyMembers::delete(array("`property_member_id` = ?", $this->getId()));
// delete permissions
ContactMemberPermissions::delete(array("member_id = ?", $this->getId()));
// delete member objects (if they don't belong to another member)
$sql = "SELECT `o`.`object_id` FROM `".ObjectMembers::instance()->getTableName()."` `o` WHERE `o`.`is_optimization`=0 AND `o`.`member_id`=".$this->getId()." AND NOT EXISTS (
SELECT `om`.`object_id` FROM `".ObjectMembers::instance()->getTableName()."` `om` WHERE `om`.`object_id`=`o`.`object_id` AND `om`.`is_optimization`=0 AND `om`.`member_id`<>".$this->getId().")";
$result = DB::execute($sql);
$rows = $result->fetchAll();
if (!is_null($rows)) {
foreach ($rows as $row) {
$obj = Objects::findById(array_var($row, 'object_id'));
$obj->delete();
}
}
// clean object_members
ObjectMembers::delete("member_id = ".$this->getId());
// delete object if member is a dimension_object
if ($this->getObjectId()) {
$object = Objects::findObject($this->getObjectId());
if ($object instanceof ContentDataObject) $object->delete();
}
ApplicationLogs::createLog($this, ApplicationLogs::ACTION_DELETE, false, true, true, 'member deleted');
return parent::delete();
}
示例3: delete
function delete()
{
// change parent of child nodes
$child_members = $this->getAllChildren();
if (is_array($child_members)) {
$parent = $this->getParentMember();
foreach ($child_members as $child) {
$child->setParentMemberId($this->getParentMemberId());
if ($parent instanceof Member) {
$child->setDepth($parent->getDepth() + 1);
} else {
$child->setDepth(1);
}
$child->save();
}
}
// delete member restrictions
MemberRestrictions::delete(array("`member_id` = ?", $this->getId()));
MemberRestrictions::delete(array("`restricted_member_id` = ?", $this->getId()));
// delete member properties
MemberPropertyMembers::delete(array("`member_id` = ?", $this->getId()));
MemberPropertyMembers::delete(array("`property_member_id` = ?", $this->getId()));
// delete permissions
ContactMemberPermissions::delete(array("member_id = ?", $this->getId()));
// delete member objects (if they don't belong to another member)
$sql = "SELECT `o`.`object_id` FROM `" . ObjectMembers::instance()->getTableName() . "` `o` WHERE `o`.`is_optimization`=0 AND `o`.`member_id`=" . $this->getId() . " AND NOT EXISTS (\n\t\t\tSELECT `om`.`object_id` FROM `" . ObjectMembers::instance()->getTableName() . "` `om` WHERE `om`.`object_id`=`o`.`object_id` AND `om`.`is_optimization`=0 AND `om`.`member_id`<>" . $this->getId() . ")";
$result = DB::execute($sql);
$rows = $result->fetchAll();
if (!is_null($rows)) {
foreach ($rows as $row) {
$obj = Objects::findById(array_var($row, 'object_id'));
$obj->delete();
}
}
// delete object if member is a dimension_object
if ($this->getObjectId()) {
$object = Objects::findObject($this->getObjectId());
if ($object instanceof ContentDataObject) {
$object->delete();
}
}
return parent::delete();
}
示例4: findById
function findById($id)
{
$co = parent::findById($id);
if (!is_null($co)) {
$co->setObject(Objects::findById($id));
}
return $co;
}