Yii Framework Forum: Defining Relation Between Schema And Schema.table_Name In Restfullyii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Defining Relation Between Schema And Schema.table_Name In Restfullyii Rate Topic: -----

#1 User is offline   lankesh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 31-December 13

Posted 31 December 2013 - 02:28 AM

Hi,
I have a schema defined for each customer with schema name as {customer_name}. I have a table named customer_config for each customer schema. Now my problem is I am using restfullyii and I need to define relation between the customer schema and {customer_name}.customer_config as I want to use customer_config as a sub-resource under CustomerController class. I do not have any foreign key in {customer_name}.customer_config table and I cannot define one either. Please help me with this.

Thank you.
0

#2 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 31 December 2013 - 03:23 AM

You shouldn't use database objects with variable names. Why can't you add a FK to the customer_config table?
Don't be a dick.
0

#3 User is offline   lankesh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 31-December 13

Posted 31 December 2013 - 04:36 AM

View Postnineinchnick, on 31 December 2013 - 03:23 AM, said:

You shouldn't use database objects with variable names. Why can't you add a FK to the customer_config table?



Because we generate schema based on customer names hence customer_config is already under that particular customer's schema. Also I am not allowed to change table structure. So I do not have an option of adding FK.
For e.g. lets say customer name is 'xyz'. Then a schema named 'xyz' is automatically created for this customer and all the required tables are placed under this schema. So whenever I want to select all the rows in 'customer_config' table of customer 'xyz', I will query something like this 'select * from xyz.customer_config;'

Now the problem is as customer_config is a subresource of customer I want to access this using URL '<domain>/customer/xyz/customer_config'. But since there is no relation defined restfullyii is not decoding this URL.
0

#4 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 31 December 2013 - 07:26 AM

You can define relations in AR models without having the constraints defined in the database.
Don't be a dick.
0

#5 User is offline   lankesh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 31-December 13

Posted 01 January 2014 - 05:58 AM

View Postnineinchnick, on 31 December 2013 - 07:26 AM, said:

You can define relations in AR models without having the constraints defined in the database.


How can I achieve that? Can you give me an example on how to do it?

Thank You
0

#6 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 01 January 2014 - 06:25 AM

You should first show how your current models look like and especially their relations() method. You just add requried relations there.
Don't be a dick.
0

#7 User is offline   lankesh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 31-December 13

Posted 03 January 2014 - 02:18 AM

View Postnineinchnick, on 01 January 2014 - 06:25 AM, said:

You should first show how your current models look like and especially their relations() method. You just add requried relations there.


I did a work around. I am using custom route to handle this special case.

Thank you for your time. I really appreciate that. :)

happy coding.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users