views:

56

answers:

2
 $this->facebook_applications = Doctrine::getTable('FacebookApplication')
      ->createQuery('a')
      ->execute();

I don't understand how this works at all. Why is the query just 'a' and why does that seem to get a list of the applications?

+5  A: 

The static method Doctrine::getTable() gets an object that represents the FacebookApplication table.

That object has a method called createQuery(), which creates a Doctrine_Query object for querying that table. The argment ('a'), specifies an alias for the table in the query.

So essentially Doctrine::getTable('FacebookApplication')->createQuery('a') creates a query that translates to SQL like:

SELECT * FROM FacebookApplication as a

Which, naturally, returns all rows from that table.

timdev
Thank you! I wouldn't of guessed that it's making an alias. I'd accept this as an answer but SO won't let me yet because you answered so fast :P
Chris T
+1  A: 

You can see it by using :

$this->facebook_applications->getSqlQuery()
JF Simon