for Project:

Task #234 — all table relationship deleted when create(), delete()

Attached to Project— EZPDO
Opened by Sam Washburn (samw3) - Friday, 21 Sep 2007, 2:26pm
Bug Report
Database access
Unconfirmed
No-one
Windows
Critical
Normal
CVS
Undecided
0% complete
Using adodb and mysql.
I have two models Model_Employee and Model_PayScale.
Model_PayScale has one Model_Employee.

Here is the problem code:

$rec = $m->create(Model_PayScale);
$cm = $rec->epGetClassMap();
$fields = $cm->getAllFields();
// Generates an "add" form based upon field types
$rec->delete();

When this code executes the following sql queries are run:
SELECT COUNT(*) FROM `_ez_relation_model_employee_model_payscale` WHERE 1=1

DELETE FROM `_ez_relation_model_employee_model_payscale` WHERE (`class_a`='Model_PayScale') OR (`class_b`='Model_PayScale')

THIS DELETES ALL RELATIONSHIPS IN THE JOIN TABLE! VERY DESTRUCTIVE!

I have found a work around like this:

$rec = $m->create(Model_PayScale);
$cm = $rec->epGetClassMap();
$fields = $cm->getAllFields();
// Generates an "add" form based upon field types
$rec->commit(); // <- Adds 6 extra sql queries but works.
$rec->delete();

This bug still exists in ezpdo.2007-08-04

Cheers!
This task depends upon

This task blocks these from closing

Comments (1) | Attachments (0) | Related Tasks (0/0) | Notifications (1) | Reminders (0) | History |

Comment by Sam Washburn - Friday, 21 Sep 2007, 3:01pm

There is a minor typo in the code snippit above:

$rec = $m->create(Model_PayScale);

should read:

$rec = $m->create("Model_PayScale");

Get Chitika eMiniMalls