0

以下のようなmysqlクエリでhttpsまたはhttpsのどちらの完全な現在のURLを取得するにはどうすればよいですか?

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 に答える