0

如何在下面的 mysql 查询中获取完整的当前 URL,无论是 https 还是 https ?

AND `url` = 'http://.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];'

由于上述部分不起作用

完整的字符串,我想在末尾加上 AND:

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_online WHERE `customer_id` != '0' AND date_added > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 HOUR) ");
4

1 回答 1

5
public function getRegisteredUsersOnline(){ 
 $url = "http".(!empty($_SERVER['HTTPS'])?"s":"")."//".
        $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

   $query = $this->db->prepare("SELECT COUNT(*) as `num` FROM " . DB_PREFIX . "customer_online WHERE customer_id != '0' AND `date_added` > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 HOUR) 
   AND `url` = ?");
   $query->execute( array( $url ) );
   $count = $query->fetch(2);
   return $count['num'];

}
于 2013-03-12T21:40:50.587 回答