⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

Insert 1 field to multiple tables

callback tables

  • Please log in to reply
1 reply to this topic

#1 Burhan Ahmed

Burhan Ahmed


  • Members
  • Pip
  • 1 posts

Posted 23 November 2016 - 08:22 AM

I have two table called users and payments. both at least have attribute like this.



  • id
  • name
  • number


  • user_number
  • date

and there is one filed called "User Number" if i inserted number to this field, it will be inserted to both users with attribute number and payments with attribute user_number.


is it possible?

plz help me to solve this


#2 sfthurber



  • Members
  • Pip
  • 7 posts

Posted 02 February 2017 - 02:21 PM

in relational database design the typical practice would be to include in payments table schema the foreign key of the users table.  just a thought.


but i'll answer the question you asked. in the crud for one table you would use callbacks to synchronize the corresponding attribute in the other table.


the documentation covers how to set up callbacks.


in the callback you would use codeigniter's active record classes to do the work.


see the codeigniter documentation if you are not familiar with those classes. 

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users