1

i would think that a delete would be pretty simple, I haven't been able to figure out why I'm getting these errors and the delete isn't working. I've tried hard coding the id of the record and just running that one line of code. Why would I get these errors, and how would i go about finding how to fix it.

  $this->RentalLineitem->delete(1979);

I'm getting the following errors with the simple delete:

  Warning (512): SQL Error: 1066: Not unique table/alias: 'Inventory' [CORE\cake\libs\model\datasources\dbo_source.php, line 684]

  Query: SELECT `RentalLineitem`.`ri_num`, `RentalLineitem`.`h_num`, `RentalLineitem`.`i_num` FROM `rental_inv` AS `RentalLineitem` LEFT JOIN `rental_in` AS `Rental` ON (`RentalLineitem`.`ri_num` = `Rental`.`ri_num`) LEFT JOIN `hotel` AS `Hotel` ON (`RentalLineitem`.`h_num` = `Hotel`.`h_num`) LEFT JOIN `inv` AS `Inventory` ON (`RentalLineitem`.`i_num` = `Inventory`.`id`) LEFT JOIN `inv` AS `Inventory` ON (`Inventory`.`i_num` = `RentalLineitem`.`id`) WHERE `RentalLineitem`.`id` = 1979 LIMIT 1

  Query: DELETE `RentalLineitem` FROM `rental_inv` AS `RentalLineitem` LEFT JOIN `inv` AS `Inventory` ON (`RentalLineitem`.`i_num` = `Inventory`.`id`) LEFT JOIN `rental_in` AS `Rental` ON (`RentalLineitem`.`ri_num` = `Rental`.`ri_num`) LEFT JOIN `hotel` AS `Hotel` ON (`RentalLineitem`.`h_num` = `Hotel`.`h_num`) LEFT JOIN `inv` AS `Inventory` ON (`RentalLineitem`.`i_num` = `Inventory`.`id`) WHERE `RentalLineitem`.`id` = 1979

I figured it out, as soon as I clicked the post button. Odd that I worked on it for an hour couldn't figure out what was going on, but I post the question and I imediately realize that I have 2 records in my RentalLineitem model pointing to Inventory. but I don't know how to delete the question.

1
  • Could you post your model classes, specifically RentalLineItem and Inventory? Commented Mar 9, 2011 at 12:46

1 Answer 1

2

Can you post your model associations here? I think there is a problem in the way you've hooked up your models because you can clearly see that the query seems to be joining to the same table (inv AS Inventory ) using the same alias (the reason is is failing)

Sign up to request clarification or add additional context in comments.

2 Comments

that's exacly what it was. it says I can't accept your answer for 6 minutes.
Yup, you have to wait for a bit :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.