Joomla 3x-配置文件字段

时间:2018-11-01 22:05:21

标签: mysql joomla

我已经在用户个人资料中添加了一个复选框,并且需要知道如何获取所有已选中该复选框的用户电子邮件地址的列表。我只想运行一个SQL查询,但看不到该值的存储位置。

2 个答案:

答案 0 :(得分:0)

所有配置文件数据都存储在#__user_profiles表中。要从个人资料表中检索数据,您可以执行此查询

// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);

// Select all records from the user profile table where key begins with "checkbox.".
// Order it by the ordering field.
$query->select($db->quoteName(array('user_id', 'profile_key', 'profile_value')));
$query->from($db->quoteName('#__user_profiles'));
$query->where($db->quoteName('profile_key') . ' LIKE '. $db->quote('\'checkbox.%\''));

// Reset the query using our newly populated query object.
$db->setQuery($query);

// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results = $db->loadObjectList();

您将获得所有单击您的复选框的用户的对象列表。请记住使用profile_key名称代替checkbox

答案 1 :(得分:0)

好的-我现在设法回答了我自己的问题(我将数据库导出为SQL文件,以测试用户的身份勾选了该复选框,再次导出,然后比较文件以查看发生了什么变化)。

这些值存储在jos_fields_values表中。下面的查询假定只有一个复选框-如果您有多个复选框,则还需要查询field_id,用Joomla安装的前缀替换xxx。

从xxx_users内部联接中选择电子邮件xxx_fields_values开启xxx_users.ID = xxx_fields_values.item_id

相关问题