Help/support application built with Zend Framework 1 and Doctrine 1.2.4.
Problem: when creating new support ticket without assigning staff_id (support personnel) at first, Doctrine inserts empty row in staff table, because staff_id is NULL, and no matching id with NULL value could be found in staff table.
New ticket is created, note NULL value for staff_id
INSERT INTO tickets (closable, emergency, survey_sent, brands_id, departments_id, categories_id, status_id, staff_id, subject, contacts_id, mask, initial_categories_id, last_opened, last_activity, created_at, updated_at) VALUES ('0', '1', '0', '1', '4', '6', '1', NULL, 'Cancellation Request', '5463', 'MQXB-39568', '6', '2012-06-14 03:15:49', '2012-06-14 03:15:49', '2012-06-14 03:15:49', '2012-06-14 03:15:49')
New row in staff table with some default values, this is the problem.
INSERT INTO staff (enable_dst, last_page, external_links, replies_per_page, active) VALUES ('1', '0', '0', '10', '1')
wild query appears
DELETE FROM staff_index WHERE (id = '197')
and now ticket_posts (post = staff note) table is updated with newly inserted ticket ID, and newly inserted blank row in staff table (staff_id should be NULL here)
UPDATE ticket_posts SET tickets_id = '12455', staff_id = '197', updated_at = '2012-06-14 03:15:49' WHERE id = '48113'
I’ve “solved” empty rows by setting second column (username) to not null, but not a real solution.
Is there a way to tell Doctrine, nothing to do here, move on?
( ^ bottom line )
http://doctrine.readthedocs.org/en/latest/en/manual/working-with-models.html#clearing-related-records