query big problem |
[eluser]xwero[/eluser]
The method i showed returns a result object not a query object. This means you can use the result method num_rows anymore but you can use count.
[eluser]polish[/eluser]
Xwero cam You lokinng on my controller function what I must change so that it is ok??? Code: function show() This is My first application and I will be very grateful for the help me!
[eluser]xwero[/eluser]
I find it a bit strange you going to put the method in a model named comments. If you have a comments model you must have a news model so you should call news->by_id($news_id) and comments->for_news_id($news_id). The idea about splitting up code is to make it simpler. My method was written to belong to the news model. The controller method would look like this Code: function show($news_id = '')
[eluser]TheFuzzy0ne[/eluser]
Here's a post I created with several resources to help get people in your position started with CodeIgniter - http://ellislab.com/forums/viewthread/107773/
[eluser]polish[/eluser]
Xwero I have in My news model function called news->by_id($news_id) and comments->for_news_id($news_id) like: Code: function get_news_by_id($news_id) Code: function are_comments_for_news($news_id) Now when I use Your controller show function and Your model function: Code: function get_news_item($id,$comments = false) I have two errors. 1. Undefined variable: news_item in My controller file and 2. Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\polish\system\libraries\Exceptions.php:164)
[eluser]xwero[/eluser]
If you have a get_news_by_id method you don't need to have the unchanged get_news_item method. In you comments model you just add a for_news_id method Code: function for_news_id($id) Code: function show($news_id = '') The errors you got were the result of mistakenly typing $news_item instead of $news_id as parameter for the by_id model method. I type mistakes too so check the code yourself if you copy paste it, you learn the best by finding out what went wrong.
[eluser]polish[/eluser]
Now I have no mistakes but working is no good! I check all parametr and function, all names! With the view news_loop: Code: <div class="czas"><?=$data_wpisu ?></div> I am listing all news and when I click Comments I need to load view com_loop who listing me the only one news and all comments for this news. This is code from com_loop view: Code: <?PHP echo $news_text; ?><br /><br /> I use function show(), for_news_id(), get_news_by_id() with right parameters and the result is not OK! How to connect that's all in a one working result??? :down: :down: :down:
[eluser]xwero[/eluser]
You still loop the news_text in the comments. the for_news_id method i wrote doesn't have news_text anymore. Also the comments variable that gets passed to the view needs the html of the comments on the news_item page.
[eluser]polish[/eluser]
What can I do now??? Create a new view or controller file??? What I must still change??? I need solution that when I click Comments I would like to open a view with one news and all comments!
[eluser]polish[/eluser]
I have the solution. Maybe it isn't optiumum but he is working ok! I created a new view com_news who listing Me the only one news and the view com_loop who loop Me all comments for this news! This is the working controller function: Code: function show() The topic is SOLVED!!! |
Welcome Guest, Not a member yet? Register Sign In |