tags:

views:

10

answers:

0

Hello Good People!

i've been banging my head against the wall over the past hour about this Exception :

The root class of the query (alias b) must have at least one field selected

on a small school hotel booking project here is the part of the schema concerned

RoomType:
  actAs: [Timestampable]
  tableName: room_type
  columns:
    name: string(100)
    number_of_bed: integer

Room:
  tableName: room
  columns:
    id:
      type: string(36)
      primary: true
    room_number: integer
    price: decimal
  relations:
    RoomType:
      class: RoomType
      local: type_id
      foreign: id

RoomBooking:
  tableName: roombooking
  actAs: [Timestampable]
  columns:
    id:
      type: string(36)
      primary: true
      room_id: string(36)
      checkin_date: date
      checkout_date: date
      is_cancelled: boolean
  relations:
    Room:
      class: Room
      local: room_id
      foreign: id

i tripped out certain field for sake of simplicity and having short post.So basically i wanted to query for the total, the type of rooms booked each day of a certain month.i wanted things simple so for now i assumed booking are just for 24 hours so for now i'm just looking at checkin date.here is the query

$q = Doctrine_Query::create ()
->select("SUM(COUNT(b.id)), b.checkin_date as DATE, t.name")
->from ("Hotel_Model_RoomBooking b" )
->leftJoin("b.Room r")
->leftJoin("r.RoomType t")
->where ("b.checkin_date > ? AND b.checkin_date < ?", array ($first, $last))
->groupBy("b.checkin_date, t.name");

$result = $q->fetchArray ();    

b.checkin_date is one field of the root class so i have this and b.id selected, and up to now i can't figure it out.What do you think? what am i doing wrong here? thanks for reading and thanks in advance for your help