Doubt in Insert, update and delete with Codeigniter Framework?

Asked

Viewed 877 times

2

I have a question related to insertion, alteration and removal of records in the Mysql database. For example, imagine a banknote table, where all the information in that note is recorded, such as supplier data, carrier data and taxes to be collected. And we also have a nota_items table, where the items of this note will be inserted. Well, in structured PHP, I would do it like this: First I would do an INSERT to register the data of the note table and then I would do another INSERT to register the data of the nota_items table with the last id of the note table in the nota_items table referencing the two tables. My question is the following, in the Codeigniter Framework is there any mechanism or function that does this automatically? Or will I have to implement the same idea of structured PHP? I hope I have been clear in my doubt and thank you already!

  • 4

    @Gwer is good your initiative to help improve the posts. It is suggested to take advantage in these cases and better break the paragraphs, and also hit keyword nomenclatures and technical terms, etc. For more details formatting, if you do not know the details, see this link: Help from the Markdown and also here: How we should format questions and answers?

  • 1

    @Bacco Ok, thanks for the suggestion! I’m a little while here on the forum. I’m happy to help, and I will improve that yes. ;)

  • @GWER does not know if you have noticed that several issues of yours are being rejected and those that are approved need improvements. Then review what you’re editing to see where you’re failing and can improve. As already said, the initiative is good but the issues need to be substantial and should really improve the posting. http://answall.com/users/22780/gwer?tab=activity&sort=suggestions

3 answers

0


I believe that there is no way, you will have to do both Inserts, it is even easier using the functions passed by Andrew Maxwell and GWER

0

  • Good morning @Guilherme Wermann, I think you might not understand my question. My question is about how to insert, change or delete data into two or more related tables in codeigniter? Do you have any idea how I can do this?

  • I believe it is not possible, you would have to do two Inserts.

0

Yes, there is a function of the database that does this procedure $this->db->insert_id(), it takes the last id registered in the database. Vlw

  • Good morning @Andrewmaxwell, I think you misunderstood my question. My question is about how to insert, change or delete data into two or more related tables in codeigniter? Do you have any idea how I can do this?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.