Problems with database relations with symfony fram

2019-08-31 08:23发布

Currently developing an application using the newest version of symfony, obtained through PEAR. This is my exact schema configuration

propel:

 user:
  id:
  name:     { type: varchar(255), required: true }
  level:    { type: integer, required: true, default: 1 }
  created_at:    

 post:
  id:
  title:     { type: varchar(255), required: true }
  post:      { type: longvarchar, required: true }
  user_id:   
  created_at:
  updated_at:

 comment:
  id:
  relation:  integer
  comment:   { type: varchar(300), required: true }
  nick:      { type: varchar(100), required: true }
  created_at:
  updated_at:

The awake and aware of you have probably noticed that user_id in post is a foreign key to user. According to the definite guide; [quote title=Quote:](columns ending with _id are considered to be foreign keys, and the related table is automatically determined according to the first part of the column name).[/quote]

Whenever I try to build EITHER filters or FORMS (build-filters/build-forms/build-all) I get the follwing error message.

>> propel    generating form classes
  -----> Cannot fetch TableMap for undefined table: user.  Make sure you have the static MapBuilder registration code after your peer stub class definition. <------
[?php
/**
 * Post form base class.
 *
 * @package    ##PROJECT_NAME##
 * @subpackage form
 * @author     ##AUTHOR_NAME##
 * @version    SVN: $Id: sfPropelFormGeneratedTemplate.php 16976 2009-04-04 12:47:44Z fabien $
 */
class BasePostForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'title'      => new sfWidgetFormInput(),
      'post'       => new sfWidgetFormTextarea(),
      'user_id'    => new sfWidgetFormPropelChoice(

I've also tried defining the foreignTable and foreignReference in my schema, but without luck. This is a fresh symfony-project, only created to debug this error. I've tried using singular and plural names for my tables. Am I doing something horribly wrong, or is this a solid bug? Appreciate ANY input, this is driving me crazy!

I have a forum thread over at symfony's official community, here: http://forum.symfony-project.org/index.php/m/77979/ - there's been some suggestions (like how I forgot to use a tilde and that "user" is a pre-defined class, but the problems remains SOLVED [edited] as of now.

One free internet hug, major props and a free space shuttle to the mighty soul who come up with a solution! (disclaimer: there's actually no free space shuttle)

1条回答
萌系小妹纸
2楼-- · 2019-08-31 09:17

Update: PROBLEM HAS BEEN SOLVED! ... after countless hours of back tracking and debugging.

The issue was caused by a TABLE prefix manually coded in in propel.ini like this:

; custom table prefix
propel.tablePrefix = mindmonkey_

There's no communication with schema.yml and the propel.ini or something like that, so everything bugged up. My conclusion from this is: forget prefixes, just use a dedicated schema for each project... I just used prefix as a habit, always done - but never again unless specifically instructed to do so!

查看更多
登录 后发表回答