我有以下型號:嵌入表單不保存正確
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
正如你看到的,我WebPromocion
對象有兩個字段引用WebFoto
對象(「照片」領域,「傳單」字段) 。我爲WebPromocion
寫了一個表格,嵌入WebFoto
的一個表格,一個名爲'foto',另一個名爲'flyer'....我用netbeans調試過它,它似乎很好地構建了這些對象,它保存了嵌入對象,但是當它要拯救的WebPromocion
,SQL查詢如下:
INSERT INTO WebPromocion (foto, nombre, desde, hasta, descripcion, status,
flyer) VALUES (?, ?, ?, ?, ?, ?, ?) - (5, prueba, 2011-12-29, 2011-12-29,
wepale, A, Array)
調試時,我發現,傳遞給負責執行的函數參數是錯誤的:
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'))))
所以,對於第一個外鍵字段('foto'),它放置了正確的值(在這種情況下爲'5',相應的(相關WebFoto
的id或主鍵),但對於第二個('傳單'),它放置代表WebFoto
對象的數組,而不是其主鍵。
我不知道該怎麼做才能解決這個問題......我嘗試過使用一個空格來嵌入WebFotoForm
s,並將其嵌入到WebPromocionForm
中,但這種方式甚至沒有保存WebFoto
對象......我認爲問題可能存在甚至是一個調節問題,而不是有兩個外鍵('foto'和'flyer'),我將不得不有一個多對多的關係......但這只是一個假設,我試圖以避免我的模型的變化...
看起來像問題是你有你的關係配置翻了一番。 Iam不知道我確實遇到過你的問題,但我知道它從來沒有爲我這樣工作。 嘗試僅在一側進行定義。 – palmic 2012-01-06 09:00:47