I have the following model:
WebPromocion:
connection: doctrine
tableName: WebPromocion
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
nombre:
type: string(100)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
foto:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
flyer:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
desde:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
hasta:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
descripcion:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
status:
type: string(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
WebFoto:
local: foto
foreign: id
type: one
WebFoto_2:
class: WebFoto
local: flyer
foreign: id
type: one
WebPromocion_Producto:
local: id
foreign: promocion
type: many
WebFoto:
connection: doctrine
tableName: WebFoto
columns:
id:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
ruta:
type: string(500)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
archivo:
type: string(150)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
nombre:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
alt:
type: string(255)
fixed: false
unsigned: false
primary: false
default: ''
notnull: true
autoincrement: false
width:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
height:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
map:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: false
autoincrement: false
title:
type: string(500)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
thumbnail:
type: string(500)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
WebFotoMap:
local: map
foreign: id
type: one
WebNoticia:
local: id
foreign: foto
type: many
WebPromocion:
local: id
foreign: foto
type: many
WebPromocion_2:
class: WebPromocion
local: id
foreign: flyer
type: many
As you can see, my WebPromocion
object has two fields referencing WebFoto
objects ('foto' field, and 'flyer' field). Im writing a form for WebPromocion
, embedding two forms for WebFoto
, one called 'foto' and the other called 'flyer'.... I have debugged it with netbeans, and it seems to construct well the objects, it save the embedded objects, but when it is going to save the the WebPromocion
, the sql query is the following:
INSERT INTO WebPromocion (foto, nombre, desde, hasta, descripcion, status,
flyer) VALUES (?, ?, ?, ?, ?, ?, ?) - (5, prueba, 2011-12-29, 2011-12-29,
wepale, A, Array)
While debugging, i found that arguments passed to the function responsible of executing were wrong:
exec('INSERT INTO WebPromocion (foto, nombre, desde, hasta, descripcion, status,
flyer) VALUES (?, ?, ?, ?, ?, ?, ?)', array('5', 'prueba', '2011-12-29',
'2011-12-29', 'wepale', 'A', array('nombre' => 'radioactivo', 'alt' =>
'radioactivo', 'width' => 100, 'height' => 100, 'title' => 'help!!!', 'maps' =>
array('map' => array('name' => 'map2', 'areas' => array('area_1' => array(
'shape' => 'rect', 'coords' => '0,0,100,100', 'href' => 'google.com', 'alt'
=> 'google', 'title' => 'google', 'id' => null)), 'id' => null)), 'id' =>
null, 'archivo' => object('sfValidatedFile'))))
so, for the first foreign key field ('foto'), it places the correct value ('5' in this case, which corresponds to the id or primary key of the related WebFoto
), but for the second one ('flyer'), it places the array representing the WebFoto
object, instead of its primary key...
I don't know what to do to fix this... I have tried using an empty form to embed both WebFotoForm
s, and embedding this one in the WebPromocionForm
, but this way it doesn't even save the WebFoto
objects... I think the problem may be even a modelation problem, that instead of having the two foreign keys ('foto' and 'flyer'), i would have to have a many-to-many relationship... but that's just an assumption , and I'm trying to avoid changes in my model...