Closed meysamabl closed 6 years ago
I need more information. You're saying the column name should be used and not the name of the value? $Id isn't a valid column name. Do you mean $Id is the name of the field for the foreign key and the database column name for that field is some_id?
Will you post the invalid SQL the trigger tool is generating? (not the whole script)
This is the error I am getting:
$php public/index.php audit:trigger-tool:create | mysql -uroot -p portalapp Enter password: ERROR 1054 (42S22) at line 76: Unknown column 'id' in 'NEW'
These are the two attributes in my entity I found out is causing the error:
` /**
/***/ protected $dateUpdated;`
I am giving them explicit column name in the ORM\Column attribute.
This is just a part of generated trigger script:
INSERT INTO audit.user_channel_preference_linker_AuditLog (
id,
dateUpdated,
user_id,
pref_id, revisionEntity_id) VALUES (OLD.id, OLD.dateUpdated, OLD.user_id, OLD.pref_id, get_revision_entity_audit('mynamespace\\Entity\\UserChannelPreference', 'delete') );
If you notice, the "id" and "dateUpdated" are not the correct column names in my table. Of course I had to change couple of places inside the generated script to make it working. (changing the id to user_channel_id and dateUpdated to date_updated)
Fix would be to Replace Line 185 in \ZF\Doctrine\Audit\Tools\Generator\Trigger\MySQL with
foreach ($classMetadata->getColumnNames() as $fieldName) {
Fixedin #5
Hello, The TriggerTool uses the property name to generates the triggers. I have used @ORM\Column(name=some_id) but my property name was $Id. And when I was running the trigger-tool:create and pipe it to MySQL target database, I was getting error that the columns does not exist. I had the same issue with couple of other properties in my entity class. I had to manually update the generated trigger script and port it to MySQL. Is there a way to fix the issue?
Thanks,