本文整理汇总了PHP中ResultSet::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultSet::create方法的具体用法?PHP ResultSet::create怎么用?PHP ResultSet::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultSet
的用法示例。
在下文中一共展示了ResultSet::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_zombies
/**
* Returns users whose last login is prior from $ceiling
*
* @param int|string $ceiling last login date
* @param bool $active_only if true returns only active users. Otherwise returns all users.
* @return ResultSet
*/
static function list_zombies($ceiling, $active_only = true)
{
$ceiling = is_numeric($ceiling) ? (int) $ceiling : strtotime($ceiling);
$ceiling = date('Y-m-d H:i:s', $ceiling);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$login_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT
user.user_id,
user.firstname,
user.lastname,
user.username,
user.auth_source,
user.email,
user.status,
user.registration_date,
user.active,
access.login_date';
global $_configuration;
if ($_configuration['multiple_access_urls']) {
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$current_url_id = api_get_current_access_url_id();
$sql .= " FROM {$user_table} as user, {$login_table} as access, {$access_url_rel_user_table} as url\n WHERE\n access.login_date = (SELECT MAX(a.login_date)\n FROM {$login_table} as a\n WHERE a.login_user_id = user.user_id\n ) AND\n access.login_date <= '{$ceiling}' AND\n user.user_id = access.login_user_id AND\n url.login_user_id = user.user_id AND url.access_url_id={$current_url_id}";
} else {
$sql .= " FROM {$user_table} as user, {$login_table} as access\n WHERE\n access.login_date = (SELECT MAX(a.login_date)\n FROM {$login_table} as a\n WHERE a.login_user_id = user.user_id\n ) AND\n access.login_date <= '{$ceiling}' AND\n user.user_id = access.login_user_id";
}
if ($active_only) {
$sql .= ' AND user.active = 1';
}
return ResultSet::create($sql);
}
示例2: is_active
/**
* Returns true if the gradebook is active and visible in a course, false
* otherwise.
*
* @param int $c_id Course integer id, defaults to the current course
* @return boolean
*/
public static function is_active($c_id = null)
{
$name = 'gradebook';
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * from {$table} WHERE variable='course_hide_tools' AND subkey='{$name}'";
$setting = ResultSet::create($sql)->first();
$setting = $setting ? $setting : array();
$inactive = isset($setting['selected_value']) && $setting['selected_value'] == 'true';
if ($inactive) {
return false;
}
$c_id = $c_id ? intval($c_id) : api_get_course_int_id();
$table = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT * from {$table} WHERE c_id = {$c_id} and name='{$name}'";
$item = ResultSet::create($sql)->first();
if (empty($item)) {
return true;
}
return $item['visibility'] == '1';
}
示例3: list_inactive_courses
/**
*
* @return ResultSet
*/
static function list_inactive_courses($ceiling, $visibility_level = COURSE_VISIBILITY_REGISTERED)
{
$ceiling = is_numeric($ceiling) ? (int) $ceiling : strtotime($ceiling);
$ceiling = date('Y-m-d H:i:s', $ceiling);
$visibility_level = $visibility_level ? $visibility_level : '0';
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT\n c.*,\n cat.name AS category\n FROM\n {$table_course} AS c\n LEFT JOIN\n {$table_category} AS cat\n ON\n c.category_code = cat.code\n WHERE\n c.visibility >= {$visibility_level} AND\n c.last_visit<='{$ceiling}'\n ";
return ResultSet::create($sql);
}