CodeIgniter Forums
How to find out member variables and functions of CI_Model and CI_Controller. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to find out member variables and functions of CI_Model and CI_Controller. (/showthread.php?tid=43229)

Pages: 1 2


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Crusoe[/eluser]
For example, I found out by trial and error that this also works :

Code:
class ProductModel extends CI_Model {
   function get_products() {
    $query = $this->db->query('select blah, blah products');
    }
}

I just guessed that db might support a method a method called "query" and tried it, it worked.

Is there any way of finding what are the members and methods of the base classes in CI ?

I tried looking through Loader.php, but it confuses me completely. Is there some documentation somewhere that explains how Loader.php works ?


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]LuckyFella73[/eluser]
Quote:I just guessed that db might support a method a method called “query” and tried it, it worked.

Have a look at the amazing Userguide - you will be surprised Wink
http://ellislab.com/codeigniter/user-guide/


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Crusoe[/eluser]
[quote author="LuckyFella73" date="1309878918"] Have a look at the amazing Userguide - you will be surprised Wink [/quote]

That sounds very witty and clever, however, there is no substance to it. Where exactly in the user guide is the db->query method mentioned ? The user guide is the first place I looked. I could not find it.


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]LuckyFella73[/eluser]
The "$this->db->query" command is decribed here:
http://ellislab.com/codeigniter/user-guide/database/results.html

My advice was ment to give you a starting point to find all available method
you asked for. And these can be found in the Userguide.

Quote:That sounds very witty and clever, ..
Unessesary commend - I just wanted to help you.

Friday

EDIT:
;-) means: "don't take that too serious"


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Crusoe[/eluser]
Sorry, I thought that was a sarcastic comment. Thanks for trying to help.

After some searching I found this thread

http://ellislab.com/forums/viewthread/69098/P0/

and this blog

http://abiola89.blogspot.com/2010/07/using-codeigniter-autocomplete-in.html

The method described in Abiosoft's blog is simply declaring the variables in the core Controller and Model classes. That's how it's normally done. The CI team could have done that instead of making the user search for workarounds.

The problem with PHP and it's accompanying frameworks is that while it makes pefect sense to the noob it's completely bewildering to someone who has used a conventional programming language (such as C++, Java etc.)before.


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]LuckyFella73[/eluser]
Maybe I got you wrong completely - are you looking
for some kind of "code hint" when writing your classes
(get a list of all available methods when starting to type) ?
At least that is what the 2 posts you linked are about.
In that case it depends on what editor you use. I hope
the articles allready helped you.


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Crusoe[/eluser]
Yes, I was trying to make auto-complete work with codeigniter. I got it working to the extent that if I type $this-> I get a list of member variables now. Next step is make the methods of these member variables visible. I am of the same opinion as gvdvenis in this post

http://ellislab.com/forums/viewthread/69098/#445367

The framework would have been easier to use if the CI team had used a "more common" way of doing things.

I was rather hoping someone from the Codeigniter dev team would post some explanation for using this approach. Maybe they have a valid reason for doing it this way. If they do, it would be nice to know what it is.


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Mirge[/eluser]
[quote author="Crusoe" date="1309905086"]Yes, I was trying to make auto-complete work with codeigniter. I got it working to the extent that if I type $this-> I get a list of member variables now. Next step is make the methods of these member variables visible. I am of the same opinion as gvdvenis in this post

http://ellislab.com/forums/viewthread/69098/#445367

The framework would have been easier to use if the CI team had used a "more common" way of doing things.

I was rather hoping someone from the Codeigniter dev team would post some explanation for using this approach. Maybe they have a valid reason for doing it this way. If they do, it would be nice to know what it is.[/quote]

Nothing in the original post made me think you were looking for code completion / code hinting.

There are several guides that explain how, as you found out. Search is your friend, which is also where you'll find their reasoning.


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Crusoe[/eluser]
[quote author="Mirge" date="1309911635"] Nothing in the original post made me think you were looking for code completion / code hinting.
There are several guides that explain how, as you found out. Search is your friend, which is also where you'll find their reasoning.[/quote]

I am not specifically interested in auto complete. The auto complete feature in the IDE is one way of seeing the members of a class you are using. In the absence of auto complete, next thing you look for is a listing of the classes and their methods in the documentation. It seems neither exists. The only way is follow the user_guide which is a type of "if you want to do this, do this" kind of documentation.


How to find out member variables and functions of CI_Model and CI_Controller. - El Forum - 07-05-2011

[eluser]Mirge[/eluser]
[quote author="Crusoe" date="1309942006"][quote author="Mirge" date="1309911635"] Nothing in the original post made me think you were looking for code completion / code hinting.
There are several guides that explain how, as you found out. Search is your friend, which is also where you'll find their reasoning.[/quote]

I am not specifically interested in auto complete. The auto complete feature in the IDE is one way of seeing the members of a class you are using. In the absence of auto complete, next thing you look for is a listing of the classes and their methods in the documentation. It seems neither exists. The only way is follow the user_guide which is a type of "if you want to do this, do this" kind of documentation.[/quote]

http://ellislab.com/codeigniter/user-guide/toc.html

"Class Reference" column is a good start.