CodeIgniter Forums
MySQL foreign key Value insert - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: MySQL foreign key Value insert (/showthread.php?tid=487)



MySQL foreign key Value insert - rushdi1987 - 12-09-2014

I made two tables

Table Name                        Column Name

debit ->   id (primary key), accountname , vid (foreign key reference to  voucher.id)
voucher -> id (primary key), voucher_no, 


I want to add voucher id no as the vid field.  How do I do that with codeigniter ??? Do i need to use LAST_INSERT_QUERY(),  custom fucntion? Please help me.

Exclamation


RE: MySQL foreign key Value insert - _this - 12-10-2014

Hello,

I'm not sure about what you need, so can you please explain more clearly your problem ?

Can you post your controller/model/view code ?

Maybe I'll can help you then... Thanks !


RE: MySQL foreign key Value insert - pravins - 12-10-2014

I think $this->db->insert_id(); will solve your problem

check this URL: http://www.codeigniter.com/userguide3/database/helpers.html


RE: MySQL foreign key Value insert - rushdi1987 - 12-10-2014

Files uploaded. i want to insert all data at once.