Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Unknown column 'orders{order_id}.id' in 'where clause'

posted by anonymous 8 years ago

When doing something like

$order = new Order(1);
$products = $order->buildProducts();

I get an error like the following:

MySQL error (Unknown column 'orders{order_id}.id' in 'where clause') in SELECT order_products.* FROM order_products WHERE orders{order_id}.id = 1 ORDER BY order_products.id ASC

My order_products table has the following definition in MySQL:

CREATE TABLE `order_products` (
 `id` int(11) NOT NULL auto_increment,
 `order_id` int(11) NOT NULL,
 `product_id` int(11) NOT NULL,
 `quantity` int(11) NOT NULL,
 PRIMARY KEY  (`id`),
 KEY `order_id` (`order_id`),
 KEY `product_id` (`product_id`),
 CONSTRAINT `order_products_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
 CONSTRAINT `order_products_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Thanks.

Can you provide the following information?

  • What version of Flourish you are running (there should be a flourish.rev file in your Flourish directory)
  • Any calls to fORM::mapClassToTable()
  • The SQL definition of the orders table
posted by wbond 8 years ago

I'm on r983 and there are no calls to fORM::mapClassToTable().

Here's the definition of orders:

CREATE TABLE `orders` (
 `id` int(11) NOT NULL auto_increment,
 `user_id` int(11) NOT NULL,
 `status` enum('Pending','Back-Order','Sent') NOT NULL,
 `date` datetime NOT NULL,
 PRIMARY KEY  (`id`),
 KEY `user_id` (`user_id`),
 CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8}}}
posted by anonymous 8 years ago

If there are no mappings, you should probably be calling:

$order = new Order(1);
$products = $order->buildOrderProducts();
posted by wbond 8 years ago

Sorry, I made a typo when writing my original post. That is exactly what I'm doing.

posted by anonymous 8 years ago

The error happens when I try to delete an order, as well (regardless of whether or not ON DELETE CASCADE is set).

posted by anonymous 8 years ago

I apologize I haven't had the time to debug this yet, things have been super-busy at work. I'll definitely try to get to it this weekend though.

posted by wbond 8 years ago