本文整理匯總了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;
}