How to add "o.idempresa" to the DQL query? - symfony1

I'm trying to build this query:
SELECT
re . *, t.tipo, m.patente, o.nombre, de.revisado
FROM
sdriving_registros_emisores re
LEFT JOIN
sdriving_turno t ON re.idturno = t.idturno
LEFT JOIN
sdriving_maquina_emisor me ON me.idmaquinaemisor = re.maquinaemisorid
LEFT JOIN
sdriving_maquina m ON me.idmaquina = m.idmaquina
LEFT JOIN
sdriving_operador o ON re.idoperador = o.idoperador
LEFT JOIN
sdriving_detalle_emisores de ON de.idregistros = re.idregistros
WHERE
o.idempresa = 1
using Doctrine DQL. This is the code I made:
Doctrine_Core::getTable('SdrivingRegistrosEmisores')
->createQuery('re')
->leftJoin('re.SdrivingTurno t')
->leftJoin('re.SdrivingMaquinaEmisor me')
->leftJoin('me.SdrivingMaquina m')
->leftJoin('re.SdrivingOperador o')
->leftJoin('re.SdrivingDetalleEmisores de')
->execute();
But if I add where('o.idempresa', $id_empresa) I get this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'o.idempresa' in 'where clause'
What's the proper way to do this? What I miss?
EDIT Added the schema.yml file:
SdrivingDetalleEmisores:
connection: doctrine
tableName: sdriving_detalle_emisores
actAs: [Timestampable]
columns:
iddetalle_emisores:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idregistros:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
fecha_registro:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
dertalle_mensaje:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
estado:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
revisado:
type: integer(1)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
modo:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
remitente:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingRegistrosEmisores:
local: idregistros
foreign: idregistros
type: one
SdrivingEmisor:
connection: doctrine
tableName: sdriving_emisor
actAs: [Timestampable]
columns:
idemisor:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
numero:
type: string(50)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingEmpresa:
local: idempresa
foreign: idempresa
type: one
SdrivingMaquinaEmisor:
local: idemisor
foreign: idemisor
type: many
SdrivingEmpresa:
connection: doctrine
tableName: sdriving_empresa
columns:
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
idlogotipo:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
nombre_empresa:
type: string(250)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
ruta_emp:
type: string(45)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingLogotipo:
local: idlogotipo
foreign: idlogotipo
type: one
SdrivingEmisor:
local: idempresa
foreign: idempresa
type: many
SdrivingMaquina:
local: idempresa
foreign: idempresa
type: many
SdrivingOperador:
local: idempresa
foreign: idempresa
type: many
SdrivingTurno:
local: idempresa
foreign: idempresa
type: many
SfGuardUserProfile:
local: idempresa
foreign: idempresa
type: many
SdrivingLogotipo:
connection: doctrine
tableName: sdriving_logotipo
columns:
idlogotipo:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: true
archivo:
type: string(250)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
SdrivingEmpresa:
local: idlogotipo
foreign: idlogotipo
type: many
SdrivingMaquina:
connection: doctrine
tableName: sdriving_maquina
actAs: [Timestampable]
columns:
idmaquina: { type: integer(8), fixed: false, unsigned: false, primary: true, autoincrement: true }
idempresa: { type: integer(4), fixed: false, unsigned: true, primary: true, autoincrement: false }
patente: { type: string(12), fixed: false, unsigned: false, primary: false, notnull: true, autoincrement: false }
relations:
Empresa:
local: idempresa
class: SdrivingEmpresa
type: one
foreignType: one
foreignAlias: MaquinaEmpresa
onDelete: CASCADE
onUpdate: CASCADE
Emisor:
local: idmaquina
class: SdrivingMaquinaEmisor
type: many
foreignType: many
foreignAlias: MaquinaEmisor
onDelete: CASCADE
onUpdate: CASCADE
SdrivingMaquinaEmisor:
connection: doctrine
tableName: sdriving_maquina_emisor
actAs: [Timestampable]
columns:
idmaquinaemisor:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idmaquina:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
idemisor:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
SdrivingEmisor:
local: idemisor
foreign: idemisor
type: one
SdrivingMaquina:
local: idmaquina
foreign: idmaquina
type: one
SdrivingRegistrosEmisores:
local: idmaquinaemisor
foreign: maquinaemisorid
type: many
SdrivingOperador:
connection: doctrine
tableName: sdriving_operador
actAs: [Timestampable]
columns:
idoperador:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
nombre:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
rut:
type: string(12)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingEmpresa:
local: idempresa
foreign: idempresa
type: one
SdrivingRegistrosEmisores:
local: idoperador
foreign: idoperador
type: many
SdrivingRegistrosEmisores:
connection: doctrine
tableName: sdriving_registros_emisores
actAs: [Timestampable]
columns:
idregistros:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
maquinaemisorid:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
idoperador:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
idturno:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
SdrivingTurno:
local: idturno
foreign: idturno
type: one
SdrivingOperador:
local: idoperador
foreign: idoperador
type: one
SdrivingMaquinaEmisor:
local: maquinaemisorid
foreign: idmaquinaemisor
type: one
SdrivingDetalleEmisores:
local: idregistros
foreign: idregistros
type: many
SdrivingTurno:
connection: doctrine
tableName: sdriving_turno
actAs: [Timestampable]
columns:
idturno:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
idempresa:
type: integer(4)
fixed: false
unsigned: true
primary: true
autoincrement: false
tipo:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
SdrivingEmpresa:
local: idempresa
foreign: idempresa
type: one
SdrivingRegistrosEmisores:
local: idturno
foreign: idturno
type: many
SfGuardUserProfile:
connection: doctrine
tableName: sf_guard_user_profile
columns:
id: { type: integer(8), primary: true }
user_id: { type: integer(8), primary: false }
idempresa: { type: integer(4), primary: false }
relations:
User:
local: user_id
class: sfGuardUser
type: one
foreignType: one
foreignAlias: SfGuardUserProfile
onDelete: CASCADE
onUpdate: CASCADE

Related

Modification of Admin Generator's Doctrine Form layout

I need to modify Admin Generator's Doctrine Form which is included by:
$this->embedRelation('MyRelation');
The default layout looks like this:
The goal - every Item of Select should be displayed as text in separate row, plus Price and Quantity:
schema.yml
Game:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
game_name: { type: string(100), notnull: true }
indexes:
it:
fields: game_name
type: unique
Campaign:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
name: { type: string(100), notnull: true }
is_active: { type: boolean, notnull: true, default: 0 }
start: { type: datetime, notnull: true }
end: { type: datetime, notnull: true }
relations:
CampaignMatrix: { onDelete: CASCADE, local: id, foreign: campaign_id, foreignAlias: CampaignMatrixCampaign }
CampaignGames:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
campaign_id: { type: integer(4), notnull: true, unsigned: true }
game_id: { type: integer(4), notnull: true, unsigned: true }
indexes:
tc:
fields: [campaign_id, game_id]
type: unique
relations:
Campaign: { onDelete: CASCADE, local: campaign_id, foreign: id, foreignAlias: CampaignCampaignGames }
Game: { onDelete: CASCADE, local: game_id, foreign: id, foreignAlias: GameCampaignGames }
CampaignMatrix:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
item_id: { type: integer(4), notnull: true, unsigned: true }
campaign_id: { type: integer(4), notnull: true, unsigned: true }
price_id: { type: integer(4), notnull: true, unsigned: true }
quantity: { type: integer(4), notnull: true, unsigned: true }
relations:
Item: { onDelete: CASCADE, local: item_id, foreign: id, foreignAlias: ItemCampaignMatrix }
Campaign: { onDelete: CASCADE, local: campaign_id, foreign: id, foreignAlias: CampaignCampaignMatrix }
Price: { onDelete: CASCADE, local: price_id, foreign: id, foreignAlias: PriceItems }
Price:
columns:
id: { type: integer(4), unsigned: true }
currency_code: { type: string(3), notnull: true }
price: { type: float, notnull: true }
indexes:
tc:
fields: [id, currency_code]
type: unique
Item:
actAs:
Timestampable: ~
I18n:
fields: [name, description, image]
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
game_id: { type: integer(4), notnull: true, unsigned: true }
product_id: { type: string(100), notnull: true }
price_id: { type: integer(4), notnull: true, unsigned: true }
quantity: { type: integer(4), notnull: true, unsigned: true }
name: { type: string(100), notnull: true }
description: { type: string(255), notnull: true }
image: { type: string(255), notnull: true }
indexes:
it:
fields: item_type
relations:
Game: { onDelete: CASCADE, local: game_id, foreign: id, foreignAlias: GameItems }
Price: { onDelete: CASCADE, local: price_id, foreign: id, foreignAlias: PriceItems }
This is how I do it:
$list = MainItemTable::getInstance()->findByGameId($gameId);
$CampaignMatrix = new CampaignMatrix();
foreach($list as $index => $item) {
$itemAssocForm = new CampaignMatrixForm($CampaignMatrix);
$itemAssocForm->item_id = $item->getId(); // Need it in the form as hidden field
$this->embedForm($item->getProductId(), $itemAssocForm);
}
And this is how I'm trying to get the value:
$this->widgetSchema['item_id'] = new sfWidgetFormInputText(array(), array('value' => $this->item_id)); // It doesn't get the Id
But I have an error:
Fatal error: Maximum execution time of 30 seconds exceeded in /vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Relation/Parser.php on line 237
If I unset price_id in CampaignMatrixForm, no error produced. How to avoid execution of select of the same data for every item row in the loop?
Item id is missing, but I need it as hidden field. How to pass CampaignMatrix ID of current row to CampaignMatrixForm?
You have to iterate on association to emebed the association form to the main form. It mays be simple if you post a part of your schema.yml.
Try to re-use this snippet :
$list = MyRelatedObjectTable::getInstance()->findAll();
foreach($list as $item)
{
$itemAssoc = AssociationTable::getInstance()->findByObjectId($this->object->id, $item->id);
if(!$itemAssoc)
{
$itemAssoc = new Association();
$itemAssoc->value_id = $itemAssoc->id;
$itemAssoc->user_id = $this->object->id;
}
$itemAssocForm = new AssociationForm($itemAssoc);
$this->embedForm('itemAssoc'.$item->code, $itemAssocForm);
}
The best way is to create a partial for that. Be aware that you need to unset the select box for the Item in the Form class or you'll lose your association. I can elaborate on that if you need more help.
you can get code from cache and move to your backend/modules/nameAPP and next edit template

SQL error foreign key constraint

I'm struggling for four days days now with an sql foreign key constraint fails and I reaaly have no idea why. I've read all I could about that subject and it seems that everything is fine.
Here is my schema.yml
Soiree:
actAs: { Timestampable: ~ }
columns:
titre: { type: string(255), notnull: true }
description: { type: blob(), notnull: true }
adresse: { type: string(255), notnull: true, unique: true }
code_postal: {type: integer, notnull: true }
ville: {type: string(255), notnull:true}
date: {type: timestamp, notnull: true }
type_id: {type: integer, notnull: true }
flyer: {type: string(255), notnull:true }
is_visible: { type: boolean, notnull:true, default:0 }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Type: {onDelete: CASCADE, local: type_id, foreign: id, alias: Types, class: Type, refClass: Soiree}
Type:
columns:
titre: {type: string(255), notnull: true}
Invitation:
actAs: { Timestampable: ~ }
columns:
titre: { type: string(255), notnull: true }
description: { type: blob(), notnull: true }
image: { type: string(255), notnull: true }
is_sent: {type: boolean, notnull:true, default:0}
adresse: { type: string(255) }
code_postal: { type: string(255) }
code_QR: {type: string(255), notnull: true }
invites_id: {type:integer }
user_id: {type:integer, notnull: true}
groupe_invites_id : {type:integer, notnull: true }
soiree_id: {type:integer, notnull:true}
relations:
Invites: { onDelete: CASCADE, local: invites_id, foreign: id, alias: invite, class: Invites, refClass: Invitation }
Groupe_invites: { onDelete: CASCADE, local: groupe_invites_id, foreign: id, alias: invit_groupes, class: Groupe_invites, refClass: Invitation }
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias :Soirees, class: Soiree, refClass: Invitation }
Groupe_invites:
actAs: { Timestampable: ~ }
columns:
titre: { type: string(255), notnull: true }
description: { type: string(255), notnull: true, unique: true }
invites_id: { type: integer, notnull: true }
soiree_id: { type: integer }
user_id: {type:integer, notnull: true}
relations:
Invites:
onDelete: CASCADE
local: invites_id
foreign: id
alias: invites
class: Invites
refClass: Groupe_invites
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias: Soiree, class: Soiree, refClass: Groupe_invites }
Invites:
columns:
nom: { type: string(255), notnull: true }
prenom: { type: string(255), notnull: true }
age: {type: integer, notnull : true }
email: {type: string(255), notnull: true, unique: true }
adresse: {type: blob(), notnull: true }
telephone: {type: integer(255), notnull: true }
soiree_id: {type: integer, notnull: true }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Soiree: { onDelete: CASCADE, local: soiree_id, foreign: id, alias: Soiree_invite, class: Soiree, refClass: Invites }
Organisateur:
actAs: {Timestampable: ~ }
columns:
nom: {type: string(255), notnull: true }
prenom: {type: string(255), notnull: true }
age: {type: integer, notnull: true }
description: {type: blob(), notnull: true }
photo: {type: string(255), notnull: true }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id, foreignAlias: Users}
Image:
columns:
titre: {type: string(255), notnull: true }
description: {type: string(255), notnull: true }
lien: {type: string(255)}
album_id: {type: integer}
user_id: {type: integer}
relations:
Album: {onDelete: CASCADE, local: album_id, foreign: id, alias: Albums, class:Album, refClass:Image}
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id}
Album:
columns:
titre: {type: string(255), notnull: true }
description: {type: blob(), notnull: true }
user_id: {type:integer, notnull: true}
relations:
sfGuardUser: {onDelete: CASCADE, local: user_id, foreign: id}
And I have an error of type:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (soiree.invitation, CONSTRAINT invitation_ibfk_1 FOREIGN KEY (invites_id) REFERENCES invitation (id) ON DELETE CASCADE)
I really need help on this one, thank you !
I typically add the id column to my tables. Apply this to the tables where it makes sense:
id: { type: integer, primary: true, autoincrement: true }

symfony foreign key one-to-many

I have two tables A (Utenti) e B (Dispositivi); on B there is a foreign key to A (one Utente->many Dispositivi). I used symfony admin generator. Can I generate a link for each Utente that list me all the related Dispositivi in the Dispositivi view. Is it possible this?
schema.yml
Dispositivi:
connection: doctrine
tableName: dispositivi
columns:
id_dispositivo:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
device_id:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
utente_fk:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Utenti:
local: utente_fk
foreign: id_utente
type: one
Utenti:
connection: doctrine
tableName: utenti
columns:
id_utente:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
username:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
password:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
tipo:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
Dispositivi:
local: id_utente
foreign: utente_fk
type: many
Servizi:
local: id_utente
foreign: utente_fk
type: many
Here is a good reference for doctrine code:
http://redotheweb.com/2008/07/08/comparing-propel-doctrine-and-sfpropelfinder/
(especially if fou are used to propel.)
First, add a partial in the generator.yml file.
Then do something like this:
<?php
$dispositivis = $utente->Dispositivis;
?>
<?php foreach ($dispositivis as $d): ?>
<?php echo link_to($d->getTipo(), 'module_name/action_name?id='. $d->getIdDispositivo()) ?><br />
<?php endforeach ?>

Cannot generate a module for a model without a primary key

I have a Heading table/model and I also have a "heading" module. When I go to the heading module, which has worked fine in the past, it now gives me this error:
Cannot generate a module for a model without a primary key (Heading)
This is odd to me because my schema.yml for Heading looks like this:
Heading:
connection: doctrine
tableName: heading
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
referenced_table_name:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
column_name:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
label:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
position:
type: integer(4)
fixed: false
unsigned: true
primary: false
notnull: true
autoincrement: false
import_profile_id:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
note:
type: string()
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
created_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
default: '0000-00-00 00:00:00'
notnull: true
autoincrement: false
updated_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
default: '0000-00-00 00:00:00'
notnull: true
autoincrement: false
relations:
ImportProfile:
local: import_profile_id
foreign: id
type: one
TotalFromFile:
local: id
foreign: heading_id
type: many
Note the primary key:
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
I suspect it has something to do with this other problem I'm having. Any ideas?
Turns out the problem was that I had defined HeadingTable::getTables() and HeadingTable::getColumns(). Doctrine didn't like that.

Doctrine does not export relation properly

I've got a MySQL 5.1.41 database which i'm trying to fill with doctrine, but doctrine does not insert the relations correctly. My YAML is:
Locatie:
connection: doctrine
tableName: locatie
columns:
loc_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
org_id:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
naam:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
straat:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
huisnummer:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
huisnummer_achtervoegsel:
type: string(3)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
plaats:
type: string(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
postcode:
type: string(6)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
telefoon:
type: string(12)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
opmerking:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
inloggegevens:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Organisatie:
local: org_id
foreign: org_id
type: one
onDelete: CASCADE
onUpdate: CASCADE
Organisatie:
connection: doctrine
tableName: organisatie
columns:
org_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
naam:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
straat:
type: string(30)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
huisnummer:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
huisnummer_achtervoegsel:
type: string(3)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
plaats:
type: string(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
postcode:
type: string(6)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
telefoon:
type: string(12)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
opmerking:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Locatie:
local: org_id
foreign: org_id
type: many
Now if a make an organisation and then create a location which has a foreignkey to organisation everything is fine. but when i try to update the org_id with phpmyadmin i get a contraint error. If i manually set the foreign key to ON_UPDATE CASCADE it does work.
Why does doctrine not set this option?
I got it to work in Propel, but i really want to use doctrine for this.
Well, you can't update the org_id because it's referenced by the location table. If you change it, it would mean that the organisation has a location that does not exist --- the foreign key fails. Insert your location data in first, and then all the location values become possible values for organisations, or alternatively use onCascade actions as you mention.
Also, something you can do is define the Organisatie table first, and include the relation declaration only for this table (one definition is enough for Doctrine). Now the Locatie table becomes referenced, and you can play with its keys freely. Of course, you still cannot reference something from the Organisatie table that does not exist.
I also spot that your schema currently says that "one organisation has many locations" although I'm guessing you've intended "one location has many organisations". If this is indeed the case, change the Organisatie->relations->Locatie to "type: one, foreignType: many", and remove the relationship declaration from your Locatie table.
Hope that helps.

Resources