Hoi

When i use the hotel-booking/search page on my multilingual site all the translations from one hotel-room are shown in the results. I have installed i18N and noticed that in drupal 7 the function i18n_get_language() is no longer available.

I edited the hotel_booking_util.inc from 370 and further and changed:

if (function_exists('i18n_get_lang')) {
//language testing
$sql .= " AND n.language IN (':null', ':language')";
$params[':null'] = ''; //no language
$params[':language'] = i18n_get_lang(); //current language
}

into:

if (function_exists('i18n_language')) {
//language testing
$sql .= " AND n.language IN (':null', ':language')";
$params[':null'] = ''; //no language
$params[':language'] = i18n_language()->language; //current language
}

Unfortunately this doesn't work out as i had hoped :)

It creates now the following error:

PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT hbrt.nid FROM {hotel_booking_room_types} hbrt INNER JOIN {node} n ON hbrt.vid = n.vid WHERE CASE WHEN n.tnid = 0 THEN n.nid ELSE n.tnid END IN (SELECT nid FROM ( SELECT nid, COUNT(*) AS nights FROM {hotel_booking_availability_calendars} WHERE calendar_dt >= :check_in1 AND calendar_dt < :check_out2 /*this has to be less than as they dont stay this night*/ AND minimum_stay <= :nights1 AND minimum_occupancy <= :occupants1 AND available > 0 GROUP BY 1) AS nights WHERE nights.nights = :nights2 ) AND CASE WHEN n.tnid = 0 THEN n.nid ELSE n.tnid END NOT IN ( SELECT nid FROM {hotel_booking_availability_calendars} WHERE calendar_dt = :check_in2 AND no_check_in = 1 ) AND CASE WHEN n.tnid = 0 THEN n.nid ELSE n.tnid END NOT IN ( SELECT nid FROM {hotel_booking_availability_calendars} WHERE calendar_dt = :check_out2 AND no_check_out = 1 ) AND :occupants2 BETWEEN minimum_occupancy AND capacity AND n.language IN ('%s', '%s'); Array ( [:check_in1] => 2011-08-30 [:check_out1] => 2011-09-01 [:nights1] => 2 [:occupants1] => 2 [:nights2] => 2 [:check_in2] => 2011-08-30 [:check_out2] => 2011-09-01 [:occupants2] => 2 [0] => [:language] => en ) in hotel_booking_get_available_rooms() (line 394 of /../modules/uc_hotel/hotel_booking/hotel_booking.util.inc).

Line number 394:
$results = db_query($sql, $params)->fetchAll();
foreach ($results as $room) {
$rooms[$room->nid] = $room->nid;
}
return $rooms;

Can someone help me out and tell me what i am missing here?

Thanks,
Menno

Comments

elatro’s picture

Status: Active » Fixed

Made the following changes in hotel_booking.util.inc

Changed:

if (function_exists('i18n_get_lang')) {
    //language testing
    $sql .= " AND n.language IN (':null', ':language')";
    $params[':null'] = ''; //no language
    $params[':language'] = i18n_get_lang(); //current language
  }

into:

  if (function_exists('i18n_language')) {
    $sql .= " AND n.language IN ('".i18n_language()->language."')";
  }

Works for me

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.