This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » Doctrine I18N SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mid' cannot be null..???
Doctrine I18N SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mid' cannot be null..??? [message #84409] Wed, 26 August 2009 16:24 Go to next message
shopoto
Messages: 19
Registered: July 2009
Junior Member
Hi everyone,


I'm working on sf 1.2.7 and doctrine


Here is a part of my schema.yml

medias:
  tableName: medias
  actAs:
    I18n:
      fields: [nom, legende, description] 
    # Signable:
    Timestampable:
    Sluggable:
     unique: true
     fields: [nom]
     canUpdate: true
  columns:
    mid: { type: integer(4), primary: true, autoincrement: true }
    mtid: { type: integer(4), notnull: true }
    nom: { type: string(100), notnull: false }
    legende: { type: string(255) }
    description: { type: string(255) }    
    mime: { type: string(50) }
    largeur: { type: integer(2), notnull: true }
    hauteur: { type: integer(2), notnull: true }
    url: { type: string(255), notnull: true }
  relations:
    contenus:
      local: mid
      foreign: mid
      type: many
    enseignes:
      local: mid
      foreign: logo
      type: many
    fousers:
      local: mid
      foreign: mid
      type: many
    pointsdeventes:
      local: mid
      foreign: logo
      type: many
    services:
      local: mid
      foreign: picto
      type: many
    mediasTypes:
      local: mtid
      foreign: mtid
      type: one      
      
mediasTypes:
  tableName: medias_types
  columns:
    mtid: { type: integer(4), primary: true, autoincrement: true }
    label: { type: string(100), notnull: true }



I overload the form used for the class medias in a plugin:

abstract class PluginmediasForm extends BasemediasForm
{
	public function setup()
	{
		parent::setup();
		unset
		(
		$this['updated_at'],
		$this['created_at']
		);
		
		$this->embedI18n(array('en', 'fr'));
		$this->widgetSchema->setLabel('en', 'English');
		$this->widgetSchema->setLabel('fr', 'French');
		
		$this->setWidget('url', new customWidgetFormDoctrineFichierBackend());
		$this->setValidator('url', new sfValidatorPass());
			
	}
	
	
}



fixtures used for these classes:
mediasTypes:
  mediasTypes_1:
    mtid:  1
    label: Images

medias:
  medias1:
    mediasTypes:  mediasTypes_1
    mime:  jpg
    largeur: 200
    hauteur: 200
    url: photo.jpg
    Translation:
      en:
        nom: 'Title'
      fr:
        nom: 'Titre'    


When i try a data-load everything run fine
I get a new entry in my table "medias"
and
I have 2 entry in table "medias_translation"
one for the french translation
and another one for the english...

But... (there is always a But...)

When I try to fill up the corresponding form done with admin -generator for the class medias and save it.

I fall on a blanck page and I get these error messages log:

Aug 26 16:13:45 symfony [info] {mediasActions} Call "mediasActions->executeCreate()"
Aug 26 16:13:46 symfony [info] {sfDoctrineLogger} executeQuery : SELECT m.mtid AS m__mtid, m.label AS m__label FROM medias_types m WHERE m.mtid = ? - (1 )
Aug 26 16:13:46 symfony [info] {sfDoctrineLogger} executeQuery : SELECT m.mid AS m__mid, m.mtid AS m__mtid, m.mime AS m__mime, m.largeur AS m__largeur, m.hauteur AS m__hauteur, m.url AS m__url, m.created_at AS m__created_at, m.updated_at AS m__updated_at, m.slug AS m__slug FROM medias m WHERE m.slug = ? - ( )
Aug 26 16:13:46 symfony [info] {sfDoctrineLogger} executeQuery : SELECT m.mid AS m__mid, m.mtid AS m__mtid, m.mime AS m__mime, m.largeur AS m__largeur, m.hauteur AS m__hauteur, m.url AS m__url, m.created_at AS m__created_at, m.updated_at AS m__updated_at, m.slug AS m__slug FROM medias m WHERE m.slug = ? - ( )
Aug 26 16:13:46 symfony [info] {sfDoctrineLogger} executeQuery : SELECT m.mid AS m__mid, m.slug AS m__slug FROM medias m WHERE m.slug LIKE ? - (% )
Aug 26 16:13:46 symfony [info] {sfDoctrineLogger} executeQuery : INSERT INTO medias_translation (mid, lang, nom, legende, description) VALUES (?, ?, ?, ?, ?) - (, en, , ,  )
Aug 26 16:13:46 symfony [err] {Doctrine_Connection_Mysql_Exception} SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mid' cannot be null




I have a mid null on the only one insert query
Cause it seems that it try to save a translation record in the translation table of class medias (=>medias_translation) BEFORE it even try to save my media..???




How the hell could it be possible?
Whereas in the Cli with a doctrine:data-load everything ran fine..?

Any ideas guys?
Confused

[Updated on: Wed, 26 August 2009 16:31]

Re: Doctrine I18N SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mid' cannot be null. [message #85082 is a reply to message #84409 ] Wed, 09 September 2009 22:24 Go to previous messageGo to next message
MrMoins  is currently offline MrMoins
Messages: 8
Registered: May 2008
Location: Marseille, France
Junior Member

Hi,
did you find the solution ?
I've the same problem :-/

Thank you

UPDATE 15/09: still haven't found :-/

[Updated on: Tue, 15 September 2009 17:07]

Re: Doctrine I18N SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mid' cannot be null. [message #98795 is a reply to message #85082 ] Mon, 10 May 2010 16:45 Go to previous messageGo to next message
shopoto
Messages: 19
Registered: July 2009
Junior Member
Unfortunately last time, I didn't solve this bug but today i'm facing this pb again.
And this time I won't be able to go on by getting around this bug. I really need to solve this one.

Maybe have you solve this pb?

Or anyone else?


Confused
Re: Doctrine I18N SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'mid' cannot be null. [message #102490 is a reply to message #84409 ] Wed, 14 July 2010 19:21 Go to previous message
kraftmalz  is currently offline kraftmalz
Messages: 1
Registered: July 2010
Junior Member
I had the same problem this afternoon and fixed it the following: I tried to instanciate a new Object and made a validation mistake, so parent object to the translations couldn't be saved (-> no id created -> no id availiable to link back from the translation object to its parent).

Hope it helped.

Cheers, Felix
Previous Topic:Problem with Left Join
Next Topic:i18n Date validation problem
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software