Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:15:20+00:00 2026-06-06T15:15:20+00:00

I have the following model: WebPromocion: connection: doctrine tableName: WebPromocion columns: id: type: integer(4)

  • 0

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 WebFotoForms, 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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:15:22+00:00Added an answer on June 6, 2026 at 3:15 pm

    I think your model it’s a little messy (actually, I think it’s some autogenerated schema.yml). Maybe there’s some info missing (as Producto entity).
    Here some tips that maybe can help you define your model manually and orderly (assuming Doctrine 1.2):

    • dont define ids columns. Doctrine create it for you as an bigint, PK and AI.
    • dont use columns or relations with name ended “_NN”. Doctrine has some troubble with the getter and setter methods.
    • end your FK column name with “_id”
    • define only 1-n, 1-1 and n-m relations, n-1 relations should be defined in the opposite model entity, and use the foreignAlias for accesing inversely.
    • 1-n relation: define “name”, “onDelete”, “local”, “foreign” and “foreignAlias”. If the name of the relation it’s not the referred entity model name, add the “class” for that definition. Remember that “name” and “foreignAlias” become the record getter/setter and the query joiner.
    • 1-1 relation: idem 1-n, but with type=”one” and singular foreignAlias
    • n-m relation: define “name”, “class”, “refClass”, “local” and “foreign”. Define the relation in both entities as n-m, and both semi 1-n relation in the relation-entity. In the n-m relation, local and foreign are the relation-entity model columns that point to each model.

    You model will become something like:

    WebPromocion:
      columns:
        nombre: { type: string(100), notnull: true }
        foto_id: { type: integer, notnull: true }
        flyer_id: { type: integer, notnull: false }
        desde: { type: timestamp, notnull: true }
        hasta: { type: timestamp, notnull: true }
        description: { type: clob, notnull: false }
        status: { type: string(1), notnull: true, default: 'X' } # some default value looks great for a status column
      relations:
        WebFoto: { onDelete: CASCADE, local: foto_id, foreign: id, foreignAlias: WebPromociones }
        Flyer: { class: WebFoto, onDelete: SET NULL, local: flyer_id, foreign: id, foreignAlias: WebPromociones }
        Productos: { class: Producto, refClass: WebPromocionProducto, local: webpromocion_id, foreign: producto_id } 
    
    webFoto:
      columns:
        ruta: { type: string(500), notnull: true }
        archivo: { type: string(150), notnull: true }
        nombre: { type: string(255), notnull: true, default: '' }
        width: { type: integer(4), notnull: true }
        height: { type: integer(4), notnull: true }
        map: { type: integer(4), notnull: false }    
        title: { type: string(500), notnull: false }
        thumbnail: { type: string(500), notnull: false }
    
    
    Producto:
      relations:
        WebPromociones: { class: WebPromocion, refClass: WebPromocionProducto, local: producto_id, foreign: webpromocion_id } 
    
    WebPromocionProducto:
      columns:
        producto_id: { type: integer, notnull: true }
        webpromocion_id: { type: integer, notnull: true }
      relations:
        Producto: { onDelete: CASCADE, local: producto_id, foreign: id, foreignAlias: WebPromocionesProductos }
        WebPromocion: { onDelete: CASCADE, local: webpromocion_id, foreign: id, foreignAlias: WebPromocionesProductos }
    

    based on the relations name (the left part from “:”), with any $webPromocion object you can do (

    $webPromocion->getWebFoto(), ->getFlyer(), ->getProductos().
    

    in any webPromocion table query, you can do

    ->innerJoin('wp.WebFoto wf'), ->innerJoin('wp.Flyer'), ->innerJoin('wp.Productos')
    

    based on the foreignAlias, with any $webFoto object you can do:

    $webFoto->getWebPromociones()
    

    and in any webFoto table query, you can do

    ->innerJoin('wf.WebPromociones')
    

    Having a nice schema.yml it’s critical when you are developing symfony1.4-doctrine apps.
    Then, your customWebPromocionForm should looks like:

    class customWebPromocionForm extends WebPromocionForm {
      public function configure() {
        parent::configure();
        unset($this['foto_id'],$this['flyer_id']);
        $foto_object = $this->getObject()->getWebFoto();
        $flyer_object = $this->getObject()->getFlyer();
        $this->embedForm('foto_form', new customWebFotoForm($foto_object));
        $this->embedForm('flyer_form', new customWebFotoForm($flyer_object));
        // of course you should define customWebFotoForm, o simply use the default webFotoForm
      }
    }
    

    That’s all. It works when you are creating or editing some WebPromocion.

    Always remember: “the lazy man works doubly”, o “el vago trabaja doble”. Don’t use schema autogenerators.

    SFMBE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
i have following model setup class Category < ActiveRecord::Base has_ancestry :cache_depth => true, :depth_cache_column
I have the following model: class test_data_urls(models.Model): url = models.CharField(max_length=200, db_index=True) I want to
I have the following model field: name = models.ForeignKey(User, unique=False, editable=False, limit_choices_to= {'is_staff': False})
I have following model. class Comment(models.Model): type = models.CharField(max_length=21, choices=OBJECT_TYPE_CHOICES) program = models.ForeignKey(Program, db_column='object_id',
I have the following model: create_table mouldings, :force => true do |t| t.string suppliers_code
I have the following model.py : class FinancialProduct(models.Model): active = models.BooleanField(default=True) name = models.CharField(max_length=20)
I have following model: class Client(models.Model): user = models.OneToOneField(DjangoUser, unique=True) address = models.ForeignKey(Address,blank=True) class
I have the following model: public class Contact { public Contact() { Name =
I have the following model: public class Tag { public int Id { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.