php - Clarity on Code -


just looking clarity on code.

i'm looking @ controller class, has protected variables named $grid , inside there there __construct function connect mongodb, after there code:

$this->grid = $mongo->selectdb($database)->getgridfs(); 

further on in in script in class , method have code

 foreach ($this->grid->find() $file) { 

am right in thinking foreach using first defined $this->grid being $monmgo->selectdb?

many thanks

it worth reading on php5 objects , classes __construct(), $this, , method call chaining basic object-oriented implementation concepts in php.

the php method calls chained in code example, means results of 1 method being passed next (from left right).

 $this->grid = $mongo->selectdb($database)->getgridfs(); 

so code executes as:

$this->grid end being new mongogridfs object (based on return type of getgridfs().

the foreach iterating on results of mongogridfs object find() method mongogridfscursor.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -