Using database results in the controller |
[eluser]bcarter[/eluser]
Hi there I hope someone can help me as I am really stuck with this. I am using Ion_auth to build my login to an application but the principle is universal, I just don’t know it!!! Problem I want to query a ‘users’ table and use the results to insert into a different table. Here’s the Model… Code: class Login_model extends CI_Model { And the controller… Code: class Campaign extends CI_Controller { Can anyone help or explain (as clearly as possible please, like you’re talking to an idiot ;-) !) how to use data you retrieve from a query in the controller? Thanks!
[eluser]andyy[/eluser]
Why are you loading and calling methods from Search_model when you cited a model named Login_model? Have you tried using $query->row_array() instead of $query->row()? I haven't tested it but I don't know if you can return objects from the model to the controller - I've only ever returned arrays. Assuming you used $query->row_array(): Code: function add()
[eluser]haileCI[/eluser]
$this->load->model('Search_model');? it is not the Model you difind $query = $this->db->get('users', 1);? i don't know what you want to do,why do you add second parameter?
[eluser]andyy[/eluser]
[quote author="haileCI" date="1301689208"] Code: $query = $this->db->get('users', 1); [/quote] The second parameter limits the number of results. http://ellislab.com/codeigniter/user-gui...tml#select
[eluser]bcarter[/eluser]
Less haste more speed! The reason why a different model is defined is because it's an example error! I just trimmed the code out to use as an example of the problem I have. It's just a principal really, how to use data from a query in the controller! Thanks
[eluser]andyy[/eluser]
[quote author="bcarter" date="1301690758"]Less haste more speed! The reason why a different model is defined is because it's an example error! I just trimmed the code out to use as an example of the problem I have. It's just a principal really, how to use data from a query in the controller! Thanks[/quote] Alright good to know . Did you solve your problem? |
Welcome Guest, Not a member yet? Register Sign In |