本文整理匯總了PHP中Stats::validate_type方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stats::validate_type方法的具體用法?PHP Stats::validate_type怎麽用?PHP Stats::validate_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Stats
的用法示例。
在下文中一共展示了Stats::validate_type方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_latest_sql
/**
* get_latest_sql
* Get the latest sql
*/
public static function get_latest_sql($type, $user_id = null)
{
if (is_null($user_id)) {
$user_id = $GLOBALS['user']->id;
}
$user_id = intval($user_id);
$type = Stats::validate_type($type);
$sql = "SELECT `object_id` as `id` FROM user_flag" . " WHERE object_type = '" . $type . "' AND `user` = '" . $user_id . "'";
if (AmpConfig::get('catalog_disable')) {
$sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
}
$sql .= " ORDER BY `date` DESC ";
return $sql;
}
示例2: get_highest_sql
/**
* get_highest_sql
* Get highest sql
*/
public static function get_highest_sql($type)
{
$type = Stats::validate_type($type);
$sql = "SELECT `object_id` as `id`, AVG(`rating`) AS `rating` FROM rating" . " WHERE object_type = '" . $type . "'";
if (AmpConfig::get('catalog_disable')) {
$sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
}
$sql .= " GROUP BY object_id ORDER BY `rating` DESC ";
return $sql;
}
示例3: get_latest_sql
/**
* get_latest_sql
* Get the latest sql
*/
public static function get_latest_sql($type, $user_id = null)
{
if (is_null($user_id)) {
$user_id = $GLOBALS['user']->id;
}
$user_id = intval($user_id);
$sql = "SELECT `user_flag`.`object_id` as `id`, `user_flag`.`object_type` as `type`, `user_flag`.`user` as `user` FROM `user_flag`";
if ($user_id <= 0) {
// Get latest only from user rights >= content manager
$sql .= " LEFT JOIN `user` ON `user`.`id` = `user_flag`.`user`" . " WHERE `user`.`access` >= 50";
}
if (!is_null($type)) {
if ($user_id <= 0) {
$sql .= " AND";
} else {
$sql .= " WHERE";
}
$type = Stats::validate_type($type);
$sql .= " `user_flag`.`object_type` = '" . $type . "'";
if ($user_id > 0) {
$sql .= " AND `user_flag`.`user` = '" . $user_id . "'";
}
if (AmpConfig::get('catalog_disable')) {
$sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
}
}
$sql .= " ORDER BY `user_flag`.`date` DESC ";
return $sql;
}