示例#1
0
function is_favorite($id = 0)
{
    global $GET;
    $id = empty($id) && isset($GET['id']) ? $GET['id'] : $id;
    if (empty($id)) {
        return false;
    }
    if ($GLOBALS['me']) {
        return \user\main::check_favorite($GLOBALS['me']->ID, $GET['id']);
    } else {
        return false;
    }
}
示例#2
0
 public static function favorite($id, $store, $type = 'add')
 {
     global $db;
     if ($type == 'add') {
         if (!\user\main::check_favorite($id, $store)) {
             $stmt = $db->stmt_init();
             $stmt->prepare("INSERT INTO " . DB_TABLE_PREFIX . "favorite (user, store, date) VALUES (?, ?, NOW())");
             $stmt->bind_param("ii", $id, $store);
             $execute = $stmt->execute();
             $stmt->close();
             if ($execute) {
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         if ($type == 'remove') {
             $stmt = $db->stmt_init();
             $stmt->prepare("DELETE FROM " . DB_TABLE_PREFIX . "favorite WHERE user = ? AND store = ?");
             $stmt->bind_param("ii", $id, $store);
             $execute = $stmt->execute();
             $stmt->close();
             if ($execute) {
                 return true;
             } else {
                 return false;
             }
         }
     }
     return false;
 }