$this->blog_model->func() and $this->blog->func() |
[eluser]luffy[/eluser]
I want to use $this->blog->func() instead of $this->blog_model->func() How should I do If I use $this->blog->func(), it will shows : Unable to locate the model you have specified: blog
[eluser]überfuzz[/eluser]
[quote author="luffy" date="1254022315"]... If I use $this->blog->func(); ... [/quote] You might wanna read up on that first lesson in programing... ;-) Code: $this->blog->func();
[eluser]pistolPete[/eluser]
Have a look at the user guide: http://ellislab.com/codeigniter/user-gui...oader.html Quote:If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:
[eluser]steelaz[/eluser]
Don't forget that if you use $this->blog for a model, you can't name your controller "Blog".
[eluser]wiredesignz[/eluser]
[quote author="steelaz" date="1254100228"]Don't forget that if you use $this->blog for a model, you can't name your controller "Blog".[/quote] You can use blog as a model alias name and have a blog controller class, as PistolPete suggests above. (but it may be confusing)
[eluser]steelaz[/eluser]
[quote author="wiredesignz" date="1254101053"][quote author="steelaz" date="1254100228"]Don't forget that if you use $this->blog for a model, you can't name your controller "Blog".[/quote] You can use blog as a model alias name and have a blog controller class, as PistolPete suggests above. (but it may be confusing)[/quote] Thanks for correcting me, I tried it some time ago and got an error (PHP4 fault?), will try again. |
Welcome Guest, Not a member yet? Register Sign In |