⚠ 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

n-n relation Edit button issue



khashabawy
  • profile picture
  • Member

Posted 17 May 2012 - 09:47 AM

I have the following tables :

user :
- u_id
- u_ut_id

section:
- s_id
- s_name

doctor:
- d_u_id
- d_s_id

and using the following n-n relation


$crud->set_relation_n_n('u_id','doctor','section','d_u_id','d_s_id','s_name' );


with this where condition

$crud->where('u_ut_id','2');


I want to edit doctors to assign them to sections

when clicking on the Edit button it takes me to
localhost/project/index.php/control_doctors/doctors_management/edit/section1

Where section1 is the s_name

which is giving me an error saying


[b] A PHP Error was encountered[/b]

Severity: Warning
Message: Attempt to assign property of non-object
Filename: libraries/grocery_crud.php
Line Number: 1121

Manually editing the url to
localhost/project/index.php/control_doctors/doctors_management/edit/1

solves the problem

So How can i solved this ?

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 17 May 2012 - 19:36 PM

Yes,

you have to change the primary key from s_name. The real primary key is the s_id and not the s_name. If you change this in your database it will automatically works.