Jump to content


Insert 1 field to multiple tables

callback tables

  • Please log in to reply
1 reply to this topic

#1 Burhan Ahmed

Burhan Ahmed

    Newbie

  • 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.

 

users

  • id
  • name
  • number

payments

  • 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

thx



#2 sfthurber

sfthurber

    Newbie

  • 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