⚠ In case you've missed it, we have migrated 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 is an archived forum. ⚠

  •     

profile picture

Auto insert of values



miningwa
  • profile picture
  • Member

Posted 28 March 2016 - 07:32 AM

Good day! any idea how to code this? im struggling finding the right solution.. 

Scenario when adding city automatically adding values to the column city_longitude and latitude
 
table A (main)
id
province_id
city_id
city_longitude
city_latitude
 
 
 
table B (province)
id_province
province_name
 
 
table C (city)
id_city
city_name
longitude
latitude
 
 
 
$crud->set_relation('province_id','province','province_name');
  
$crud->set_relation('city_id', 'city', 'city_name');


$crud->display_as('provi_id','Province');
$crud->display_as('city_id','City');
 

How to auto insert the longitude and latitude when selecting city??

 


Paul Savostin
  • profile picture
  • Member

Posted 29 March 2016 - 17:58 PM

Hi! Using set_relation u can add only foreign key from related table, nothing more.

Actualy I dont understand why u need to add to main table field which u have in related table? U aready have link to that table with city_id - no problems to get with db query all info u need


miningwa
  • profile picture
  • Member

Posted 30 March 2016 - 01:24 AM

thanks paul for the reply. well im just wondering how to auto update it.. for example i want to add another column for table A and then i want to display it on a map.. i will only call on my table A to populate the map.. hope you get my point