Nate
Nate

Reputation: 919

Php -> operator

Can anyone tell me what the -> operator would be accessing/calling? in this context:

$query = db_select('date_formats', 'd')->extend('PagerDefault');

Is it assigning a class of PagerDefault to &query or accessing property or nested function or something? I'm just completely guessing. Thanks.

Upvotes: 1

Views: 181

Answers (3)

phihag
phihag

Reputation: 287875

It executes the method extend on the object returned by db_select. For details on objects and an introduction, refer to the PHP manual.

Upvotes: 5

Clive
Clive

Reputation: 36956

It calls the extend method of the Drupal query object, in this case it's extending the query by adding paging functionality.

Upvotes: 0

piotrp
piotrp

Reputation: 3874

You can also write it like this:

$query = db_select('date_formats', 'd');
$query->extend('PagerDefault');

First line assigns to $query an object that is returned by db_select(), the second one calls extend() method on this object.

Upvotes: 2

Related Questions