![]() |
list_fields not working on query - 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: list_fields not working on query (/showthread.php?tid=37201) |
list_fields not working on query - El Forum - 01-01-2011 [eluser]cogito[/eluser] Hi, I need to use list_fields on my query result (usgin mysql), but it's not returning anything. It's working fine for when called directly from db using table name. How can I make it work for query as well? Am I missing something or is it a bug? thanks, Slawek list_fields not working on query - El Forum - 01-01-2011 [eluser]InsiteFX[/eluser] Post your code or we will not be able to help you! InsiteFX list_fields not working on query - El Forum - 01-01-2011 [eluser]cogito[/eluser] I do not have any particular code, I have just tried to create a general code to get query result and display it as a html table. I have tried to get query from model and call Code: $query->list_fields() But the function doesn't return anything. It works when I call Code: $this->db->list_fields('users'); Should I do anything more to enable list_fields() for a query returned by Code: $query = $this->db->get('users'); I have used most simple calls, examples from user guide (user guide). I'm using simple MySQL database, currently connecting to it as a root (I will change it later on to use more restricted account). list_fields not working on query - El Forum - 01-01-2011 [eluser]InsiteFX[/eluser] You can read up on how to do it here: CodeIgniter User Guide - The Database Class CodeIgniter also has a Table Class, you can find it here: CodeIgniter User Guide - HTML Table Class InsiteFX list_fields not working on query - El Forum - 01-02-2011 [eluser]cogito[/eluser] I do read that section of user guide. My question is why example code from user guide to get list_fields() is not working for query object ($query->list_fields()) while it's working when called for a specified table ($this->db->list_fields('users')? list_fields not working on query - El Forum - 01-02-2011 [eluser]InsiteFX[/eluser] That is because it is listing all the column names in the table! Maybe you need to explain better of what you are trying to do. InsiteFX list_fields not working on query - El Forum - 04-18-2011 [eluser]Unknown[/eluser] I'm having a similar problem. The second call to the result->list_fields method returns an empty array. The full table version works fine. Here is the code and the output: Code: Code: $query = $this->db->get($mytablename); this is the first call on table results: Array ( [0] => id [1] => keyword [2] => aliaslist [3] => campaign_id [4] => contentcat [5] => keypadalias [6] => datafeed_id ) this is the second call on table results: Array ( ) this is the first call on full table: Array ( [0] => id [1] => keyword [2] => aliaslist [3] => campaign_id [4] => contentcat [5] => keypadalias [6] => datafeed_id ) this is the second call on full table: Array ( [0] => id [1] => keyword [2] => aliaslist [3] => campaign_id [4] => contentcat [5] => keypadalias [6] => datafeed_id ) For now, I'm just stuffing the results of the first call in a variable and using that for repeats. list_fields not working on query - El Forum - 04-18-2011 [eluser]toopay[/eluser] Code: $query = $this->db->get($mytablename); |