Comparing query results and assigning the ID..? |
[eluser]rvent[/eluser]
Hello, i have 10 tables the main table has a bunch of FK that link the tables together. In order to insert a record in the main table i have to insert the PK's value that relates to the especific record on the other table. i have this for one of the values and so far it works: Code: function fill_WorkOrder() i could have as many as i need of: Code: $this->db->select('PartNumberID, PartNumber'); But: 1- Would i be bale to assing several of $this->db..... to different variables like the one above..? It seems that every time the get() is used, you could then query for something else and assign it to a new variable.. 2- Is there an easier way of doing it..? since i would have to repeat a lot of code with only different queries.. i have a model that gets all the data from the old DB. i assign one of those old values to a variable and then use it to get the primary ID of a table where priority = 'highest' Any thoughts...
[eluser]rvent[/eluser]
Is this legal..? Code: $this->db->select('PartNumberID, PartNumber');
[eluser]Gavin Vickery[/eluser]
Well, first off I don't think CI Active Record methods are the best solution for this kind of query. I would write a custom query using JOIN methods. This allows you to retrieve multiple IDs from separate tables in one query. http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php UPDATE Apparently CI does support JOIN in the Active Record. Heres the link. http://ellislab.com/codeigniter/user-gui...ecord.html
[eluser]rvent[/eluser]
I found another way of doing it... I wanted to get the data from the old DB assign it to a variable that would be used to query a different DB which will return the record ID depending on the variable's value. So i wrote a few elseif in order to assign values that meet a criteria. The export of data from the old DB to new normilzed table worked with no problems at all. Thanks |
Welcome Guest, Not a member yet? Register Sign In |