Exemplo n.º 1
0
	/**
	 * <p>Возвращает данные по указанному <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#guest">посетителю</a>.</p>
	 *
	 *
	 *
	 *
	 * @param int $guest_id  ID посетителя.
	 *
	 *
	 *
	 * @return CDBResult 
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * &lt;?
	 * $guest_id = 1;
	 * if ($rs = <b>CGuest::GetByID</b>($guest_id))
	 * {
	 *     $ar = $rs-&gt;Fetch();
	 *     // выведем параметры посетителя
	 *     echo "&lt;pre&gt;"; print_r($ar); echo "&lt;/pre&gt;";
	 * }
	 * ?&gt;
	 * </pre>
	 *
	 *
	 *
	 * <h4>See Also</h4> 
	 * <ul><li> <a href="http://dev.1c-bitrix.ru/api_help/statistic/terms.php#guest">Термин "Посетитель"</a>
	 * </li></ul><a name="examples"></a>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/statistic/classes/cguest/getbyid.php
	 * @author Bitrix
	 */
	public static function GetByID($ID)
	{
		$DB = CDatabase::GetModuleConnection('statistic');
		$ID = intval($ID);

		$res = $DB->Query("
			SELECT
				G.*,
				".$DB->DateToCharFunction("G.FIRST_DATE")." FIRST_DATE,
				".$DB->DateToCharFunction("G.LAST_DATE")." LAST_DATE,
				".CStatistics::DBDateDiff("FS.DATE_LAST","FS.DATE_FIRST")." FSESSION_TIME,
				".CStatistics::DBDateDiff("LS.DATE_LAST","LS.DATE_FIRST")." LSESSION_TIME,
				FS.HITS FSESSION_HITS,
				LS.HITS LSESSION_HITS,
				C.NAME COUNTRY_NAME,
				CITY.REGION REGION_NAME,
				CITY.NAME CITY_NAME,
				G.LAST_CITY_INFO
			FROM
				b_stat_guest G
				INNER JOIN b_stat_country C ON (C.ID = G.LAST_COUNTRY_ID)
				LEFT JOIN b_stat_session FS ON (FS.ID = G.FIRST_SESSION_ID)
				LEFT JOIN b_stat_session LS ON (LS.ID = G.LAST_SESSION_ID)
				LEFT JOIN b_stat_city CITY ON (CITY.ID = G.LAST_CITY_ID)
			WHERE
				G.ID = '$ID'
		", false, "File: ".__FILE__."<br>Line: ".__LINE__);

		$res = new CStatResult($res);
		return $res;
	}