本文整理汇总了PHP中Objects::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Objects::findAll方法的具体用法?PHP Objects::findAll怎么用?PHP Objects::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::findAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: purge_trash
function purge_trash()
{
Env::useHelper("permissions");
$days = config_option("days_on_trash", 0);
$count = 0;
if ($days > 0) {
$date = DateTimeValueLib::now()->add("d", -$days);
$objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
foreach ($objects as $object) {
$concrete_object = Objects::findObject($object->getId());
if (!$concrete_object instanceof ContentDataObject) {
continue;
}
if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) {
continue;
}
try {
DB::beginWork();
if ($concrete_object instanceof MailContent) {
$concrete_object->delete(false);
} else {
$concrete_object->delete();
}
ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE);
DB::commit();
$count++;
} catch (Exception $e) {
DB::rollback();
Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
}
}
}
return $count;
}
示例2: KEY
}
}
return false;
}
if (!complete_migration_check_table_exists(TABLE_PREFIX . "processed_objects", DB::connection()->getLink())) {
DB::execute("CREATE TABLE `" . TABLE_PREFIX . "processed_objects` (\r\n\t\t\t\t `object_id` INTEGER UNSIGNED,\r\n\t\t\t\t PRIMARY KEY (`object_id`)\r\n\t\t\t\t) ENGINE = InnoDB;");
}
try {
$sql = "";
$first_row = true;
$cant = 0;
$count = 0;
$processed_objects = array();
$user = Contacts::findOne(array("conditions" => "user_type = (SELECT id FROM " . TABLE_PREFIX . "permission_groups WHERE name='Super Administrator')"));
$object_controller = new ObjectController();
$objects = Objects::findAll(array('id' => true, "conditions" => "id NOT IN(SELECT object_id FROM " . TABLE_PREFIX . "processed_objects)", "order" => "id DESC", "limit" => OBJECT_COUNT));
foreach ($objects as $obj) {
$cobj = Objects::findObject($obj);
if ($cobj instanceof ContentDataObject) {
if (!$cobj instanceof Workspace) {
$mem_ids = $cobj->getMemberIds();
if (count($mem_ids) > 0) {
$object_controller->add_to_members($cobj, $mem_ids, $user);
} else {
$cobj->addToSharingTable();
}
$cobj->addToSearchableObjects(true);
}
// add mails to sharing table for account owners
if ($cobj instanceof MailContent && $cobj->getAccount() instanceof MailAccount) {
$db_result = DB::execute("SELECT contact_id FROM " . TABLE_PREFIX . "mail_account_contacts WHERE account_id = " . $cobj->getAccountId());
示例3: while
while ($row = mysql_fetch_array($res)) {
if ($row[0] == $table_name) {
return true;
}
}
return false;
}
if (!complete_migration_check_table_exists(TABLE_PREFIX . "processed_objects", DB::connection()->getLink())) {
DB::execute("CREATE TABLE `" . TABLE_PREFIX . "processed_objects` (\n\t\t\t\t `object_id` INTEGER UNSIGNED,\n\t\t\t\t PRIMARY KEY (`object_id`)\n\t\t\t\t) ENGINE = InnoDB;");
}
$sql = "";
$first_row = true;
$cant = 0;
$count = 0;
$processed_objects = array();
$objects = Objects::findAll(array('id' => true, "conditions" => "id NOT IN(SELECT object_id FROM " . TABLE_PREFIX . "processed_objects)"));
foreach ($objects as $obj) {
$cobj = Objects::findObject($obj);
if ($cobj instanceof ContentDataObject) {
$cobj->addToSearchableObjects(true);
$cobj->addToSharingTable();
// add mails to sharing table for account owners
if ($cobj instanceof MailContent) {
$db_result = DB::execute("SELECT contact_id FROM " . TABLE_PREFIX . "mail_accounts WHERE id = " . $cobj->getAccountId());
$macs = $db_result->fetchAll();
if ($macs && is_array($macs) && count($macs) > 0) {
$pgs = array();
foreach ($macs as $mac) {
$contact_id = $mac['contact_id'];
$db_result = DB::execute("SELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = " . $contact_id);
$mac_pgs = $db_result->fetchAll();
示例4: getObjectsFromContext
/**
* Enter description here...
*
* @param Array $context: array of the selected dimensions and/or members
* @deprecated use ContentDataObjects::listing() instead
*/
static function getObjectsFromContext($context, $order = null, $order_dir = null, $trashed = false, $archived = false, $filters = null, $start = 0, $limit = null, $obj_type_types = null)
{
//Filters conditions
$filter_conditions = self::prepareFiltersConditions($filters);
$name_filter_condition = $filter_conditions[0];
$obj_ids_filter_condition = $filter_conditions[1];
$type_filter_condition = $filter_conditions[2];
//Trash && Archived conditions
$conditions = self::prepareTrashandArchivedConditions($trashed, $archived);
$trashed_cond = $conditions[0];
$archived_cond = $conditions[1];
//Order conditions
$order_conditions = self::prepareOrderConditions($order, $order_dir);
//Dimension conditions
$member_conditions = self::prepareDimensionConditions($context);
if ($member_conditions == "") {
$member_conditions = "true";
}
$limit_query = "";
if ($limit !== null && $start !== null) {
$limit_query = "LIMIT {$start} , {$limit} ";
}
if ($obj_type_types == null) {
$obj_type_types = array('content_object');
}
// $exists_member_cond: checks if the logged user deleted or archived the object then he always can see it in the trash can or archived objs panel
$trashed_by_id_cond = $trashed ? "OR `o`.`trashed_by_id` = " . logged_user()->getId() : "";
$archived_by_id_cond = $archived ? "OR `o`.`archived_by_id` = " . logged_user()->getId() : "";
$exists_member_cond = "(NOT `om`.`member_id` IS NULL {$trashed_by_id_cond} {$archived_by_id_cond})";
$sql_count = "SELECT count( DISTINCT `o`.`id` ) AS total FROM `" . TABLE_PREFIX . "objects` `o` \r\n\t\t\t\tINNER JOIN `" . TABLE_PREFIX . "object_types` `ot` ON `ot`.`id` = `o`.`object_type_id` \r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "object_members` `om` ON `o`.`id` = `om`.`object_id` \r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "project_tasks` `t` ON `t`.`object_id` = `o`.`id`\r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "project_milestones` `m` ON `m`.`object_id` = `o`.`id`\r\n\t \t\t\r\n\t\t\t\tWHERE {$trashed_cond} {$archived_cond}\r\n\t\t\t\tAND {$exists_member_cond}\r\n\t\t\t\tAND ( `t`.`is_template` IS NULL OR `t`.`is_template` = 0 )\r\n\t\t\t\tAND ( `m`.`is_template` IS NULL OR `m`.`is_template` = 0 )\r\n\t\t\t\tAND `ot`.`type` IN ('" . implode("','", $obj_type_types) . "')\r\n\t\t\t\tAND ({$member_conditions}) {$name_filter_condition} {$obj_ids_filter_condition} {$type_filter_condition} {$order_conditions}";
$total = array_var(DB::executeOne($sql_count), "total");
$sql = "SELECT DISTINCT `o`.`id` FROM `" . TABLE_PREFIX . "objects` `o` \r\n\t\t\t\tINNER JOIN `" . TABLE_PREFIX . "object_types` `ot` ON `ot`.`id` = `o`.`object_type_id`\r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "object_members` `om` ON `o`.`id` = `om`.`object_id` \r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "project_tasks` `t` ON `t`.`object_id` = `o`.`id`\r\n\t\t\t\tLEFT JOIN `" . TABLE_PREFIX . "project_milestones` `m` ON `m`.`object_id` = `o`.`id`\r\n\t \t\t\r\n\t\t\t\tWHERE {$trashed_cond} {$archived_cond}\r\n\t\t\t\tAND {$exists_member_cond}\r\n\t\t\t\tAND ( `t`.`is_template` IS NULL OR `t`.`is_template` = 0 )\r\n\t\t\t\tAND ( `m`.`is_template` IS NULL OR `m`.`is_template` = 0 )\r\n\t\t\t\tAND `ot`.`type` IN ('" . implode("','", $obj_type_types) . "')\r\n\t\t\t\tAND ({$member_conditions}) {$name_filter_condition} {$obj_ids_filter_condition} {$type_filter_condition} {$order_conditions}\r\n\t\t\t\t{$limit_query} ";
$result = DB::execute($sql);
$rows = $result->fetchAll();
$objects = array();
if (!is_null($rows)) {
$ids = array();
foreach ($rows as $row) {
$ids[] = array_var($row, 'id');
}
if (count($ids) > 0) {
$q_order = "";
if (!is_null($order)) {
if (!is_array($order)) {
$q_order = "`" . str_replace("o.", "", $order) . "` {$order_dir}";
} else {
$q_order = "";
foreach ($order as $o) {
$q_order .= ($q_order == "" ? "" : ", ") . "`" . str_replace("o.", "", $o) . "` {$order_dir}";
}
}
}
$query_params = array("conditions" => "`id` IN (" . implode(",", $ids) . ")");
if (trim($q_order) != "") {
$query_params["order"] = $q_order;
}
$objects = Objects::findAll($query_params);
}
}
$result = new stdClass();
$result->objects = $objects;
$result->total = $total;
return $result;
}