Yii Framework Forum: Problem With Related Tables - Yii Framework Forum

Jump to content

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

Problem With Related Tables Relations won't work when moving from localhost to online server Rate Topic: -----

#1 User is offline   Phyxius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-November 12

Posted 27 December 2012 - 09:57 AM

Hello! I hope you could help me.

I got a problem when copying some files from my localhost server to a online server.

I got two tables, Alumno and Proyecto

In my localhost server I can do this:

$alumno->proyecto->pre_empresa


but in the online server this gets an error.

Quote

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':ypl0)' at line 1. The SQL statement executed was: SELECT `proyecto`.`_id` AS `t1_c0`, `proyecto`.`pre_empresa` AS `t1_c1`, `proyecto`.`proyecto` AS `t1_c2`, `proyecto`.`añoFS` AS `t1_c3` FROM `proyectos` `proyecto` WHERE (`proyecto`.`_id`=:ypl0)


I don't know the reason of this, and I need this reference to work properly, I use it very often in my code.

Is there a problem for this reference in some versions of php, apache or mysql?

Please help me
0

#2 User is offline   robregonm 

  • Expert Yii Developer
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 595
  • Joined: 30-July 09
  • Location:Colombia

Posted 27 December 2012 - 10:07 AM

Hello Phyxius,
First of all, please check that you are NOT using MyISAM in your production server.
Then, check that all the foreign keys are correctly created.
And finally, check that the minimum records in the "master tables" have been inserted.

Best regards.
Ricardo Obregón

YiiFramework en Español - http://yiiframework.co/ - http://yiiframeworkenespanol.org/ - Yii Code Generator for Bootstrap
http://obregon.co/ - https://1server.co/
PHP 5.5+, nginx 1.7, MySQL(MariaDB & PerconaDB), PostgreSQL 9, Yii 2, CanJS
Follow me: @robregonm & @obregonco & @1ServerCo.
0

#3 User is offline   Phyxius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-November 12

Posted 27 December 2012 - 10:26 AM

View Postrobregonm, on 27 December 2012 - 10:07 AM, said:

Hello Phyxius,
First of all, please check that you are NOT using MyISAM in your production server.
Then, check that all the foreign keys are correctly created.
And finally, check that the minimum records in the "master tables" have been inserted.

Best regards.

Thanks for your response.

I'm working with InnoDB for my tables, and all foreing keys are correct.
Actually I exported my localhost db and imported to my production server so that should not be a problem.

I can reach the related tables by using find() and the id but I can't reach them using the access $table1->table2_id provided by yii.

Greetings
0

#4 User is offline   Phyxius 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 12-November 12

Posted 04 January 2013 - 05:59 PM

View PostPhyxius, on 27 December 2012 - 10:26 AM, said:

Thanks for your response.

I'm working with InnoDB for my tables, and all foreing keys are correct.
Actually I exported my localhost db and imported to my production server so that should not be a problem.

I can reach the related tables by using find() and the id but I can't reach them using the access $table1->table2_id provided by yii.

Greetings


I find a solution! In my Cgridview I get the model by pk.

'value' => 'Cosa::Model()->FindByPk($data->cosa_id)->cosa_name'


Thanks for the help.
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