Querying a DB with a value from a previous query? |
[eluser]dobbler[/eluser]
Hi, I'm trying to replicate this Cold Fusion code in a project. Code: <cfquery datasource="#application.dsn#" name="verify"> Where you can see that the subsequent sql calls are using the UserID value from the first verify call.. Is it possible to replicate this in CI? I've tried a couple of things but keep hitting a brick wall.. Any help would be greatly appreciated. Rob.
[eluser]bohara[/eluser]
It has been a long time since I worked with ColdFusion but I think something like this is close to what you are looking for. Code: $verify = $this->db->select('UserId', 'FirstName', 'Sirname', 'RoleId'); Cheers
[eluser]dobbler[/eluser]
Thanks bohara, much appreciated. I'm running into this problem and I've Googled it but got no results: Code: Fatal error: Call to undefined method CI_DB_mysql_driver::result_array() in /Users/rob/Sites/MMI/system/application/models/basic_mdl.php on line 38 Line 38 is: Code: $match = $verify->result_array(); It's weird.. Here's the rest of the code: Code: function verify($email, $password) { I'll try searching in this forum.. I probably should have done that in the first place.. Thanks again! Rob.
[eluser]dobbler[/eluser]
I think I found it: http://ellislab.com/forums/viewthread/67513/ I'm on a different computer so can't check just yet..
[eluser]bohara[/eluser]
I didn't test the code, I just put it together as an idea. Let me see if I can find out what is wrong.
[eluser]bohara[/eluser]
Try switching Code: $verify = $this->db->select('UserID', 'FirstName', 'Surname', 'RoleId'); To Code: $this->db->select('UserID', 'FirstName', 'Surname', 'RoleId'); Oops, We were not actually running the query we built. Also If you are on php5 you can chain the methods together and shorten the code a bit. see here Active Record - Method Chaining Hope that helps |
Welcome Guest, Not a member yet? Register Sign In |