Php 显示上次登录时新创建的用户
我已经在我的Elgg应用程序中安装了这个插件,现在我正在编辑这个插件,以显示从上次管理员登录到当前登录创建的所有用户 但是我没有从我编写的查询中得到预期的结果 这是我的index.php代码Php 显示上次登录时新创建的用户,php,plugins,elgg,Php,Plugins,Elgg,我已经在我的Elgg应用程序中安装了这个插件,现在我正在编辑这个插件,以显示从上次管理员登录到当前登录创建的所有用户 但是我没有从我编写的查询中得到预期的结果 这是我的index.php代码 case 'lasttonow': $db_prefix = elgg_get_config('dbprefix'); $joins = array("JOIN {$db_prefix}users_entity u on e.guid = u.guid"); $time =
case 'lasttonow':
$db_prefix = elgg_get_config('dbprefix');
$joins = array("JOIN {$db_prefix}users_entity u on e.guid = u.guid");
$time = time();
$options['joins'] = $joins;
options['wheres'] = "e.time_created >= u.prev_last_login";
$options['order_by'] = "e.time_created DESC";
$content = elgg_list_entities_from_metadata($options);
break;
我不明白我哪里做错了
谢谢构建的查询是“列出上次登录后创建的所有用户”。这不会得到任何结果 相反,您要做的是获取管理员的上一次登录(我假设当前登录的用户),并在查询选项中使用:
$admin = elgg_get_logged_in_user_entity();
$options['time_created_lower'] = $admin->prev_last_login;
$options['order_by'] = "e.time_created DESC";
$content = elgg_list_entities_from_metadata($options);
我已经编辑了您的代码以符合您的要求。请尝试以下代码,您将得到您期望的结果。您试图做的是错误的,您正在尝试的查询将不会显示正确的结果,因为您正在尝试添加特定用户的Prev Last Login,就像您在上面的代码中提到的那样,实际上您应该使用您登录到站点的任何用户的Prev Last Login
case 'lasttonow':
$db_prefix = elgg_get_config('dbprefix');
$joins = array("JOIN {$db_prefix}users_entity u on e.guid = u.guid");
$admin = elgg_get_logged_in_user_entity();
$times =$admin->prev_last_login;
$options['joins'] = $joins;
$options['wheres'] = "e.time_created >= {$times}";
$options['order_by'] = "e.time_created DESC";
$content = elgg_list_entities_from_metadata($options);
break;