Christopher Tarquini
Christopher Tarquini

Reputation: 11342

What does this doctrine query do?

 $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?

Upvotes: 1

Views: 495

Answers (2)

JF Simon
JF Simon

Reputation: 1245

You can see it by using :

$this->facebook_applications->getSqlQuery()

Upvotes: 2

timdev
timdev

Reputation: 62914

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.

Upvotes: 8

Related Questions