Hi there.

a...@litho:~/src/edge-web$ php -v
PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010
20:01:00)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
a...@litho:~/src/edge-web$ ./symfony -Version
symfony version 1.4.5 (/home/asr/src/edge-web/lib/vendor/symfony/lib)


I have a pretty simple schema.  Some data in fixtures is refusing to
load, claiming the required foreign key data is not present, when it
is, in fact.   Here are the relevant chunks of schema:

  people:
    _attributes: { phpName: People }
    ufid: { phpName: Ufid, type: VARCHAR, size: '8', primaryKey: true,
required: true, defaultValue: '' }
    lastname: { phpName: Lastname, type: VARCHAR, size: '20',
required: false }
    firstname: { phpName: Firstname, type: VARCHAR, size: '20',
required: false }

  certificate:
    _attributes: { phpName: Certificate }
    S_No: { phpName: SNo, type: INTEGER, size: '5', primaryKey: true,
autoIncrement: true, required: true }
    Name: { phpName: Name, type: VARCHAR, size: '50', required:
false }
    ufid: { phpName: Ufid, type: VARCHAR, size: '8', required: true,
foreignTable: people, foreignReference: ufid }


If I try to load the following file:

people:
  Allen:
    ufid: 12345678
    lastname: Rout
    firstname: Allen

certificate:
  AllenCert:
    ufid: 12345678
    Name: Allen S. Rout
    email: a...@ufl.edu
    typename: SEC


I get an error:

The object "12345678" from class "People" is not defined in your data
file.

I chased it down to a part of  sfPropelData.class.php, where it
branches on:

              if (!isset($this->object_references[$relatedTable-
>getPhpName().'_'.$value]))


If I var_dump($this->object_references), I learn that the People
objects are recorded as e.g.

 ["People_Allen"]=>
  object(People)#4347 (15) {
    ["ufid":protected]=>
    string(8) "12345678"
    ["lastname":protected]=>
    string(4) "Rout"
    ["firstname":protected]=>
    string(5) "Allen"

So, it's looking for "People_[ufid]", but the entries are getting
added to object_references as "People_[firstname]".


I'm no PHP guru, but it seems you're insisting that the field
referenced in a foreign key is the primary key of the target table.
(you're searching for [object]_[key] in your list of references).    I
don't think you can count on this.  There's no reason I can't write a
foreign key against, say, peoples' phone  numbers.

Might it be simpler to avoid trying to duplicate all the referential
integrity math, and just shove things in the database, and forward its
complaints?


- Allen S. Rout


-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to