Welcome Guest, Not a member yet? Register   Sign In
What are the difference between $this->data->total_pages and $data['total_pages']
#4

[eluser]bretticus[/eluser]
You really need to read that OOP link.

Hopefully I can provide some basic insight if you understand OOP in PHP well enough.

CodeIgniter runs from one index.php file. For this to work, CI has to load a core object (objects are also called classes.) That core object's properties and methods can be conveniently referred to in your subsequent code using PHP's built in $this variable. That's because all the subsequent classes (objects) are an extension of the core object (see what I mean about reading up on OOP?) It just so happens that CI can load a data object to the core object called data with all the properties and methods you need to do database transactions (thus, $this->data.) total_pages from $this->data->total_pages is simply a property of the data object (although it would appear that it is an extended version of that class since I am not aware of a total_pages property.) I have no idea what it refers to without context. So I can't answer:

Quote:Why $this->data->total_pages is not $this->total_pages?

As for $data['total_pages']...

That is just how you'd refer to the value stored in an array called data with an associate key called total_pages. The data array in CI convention (can be called whatever you like) is most often used to pass an array of data to a view.


Messages In This Thread
What are the difference between $this->data->total_pages and $data['total_pages'] - by El Forum - 01-21-2010, 02:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB