Hi, I am upgrading from CakePhp1.1 to Cakephp 1.2 When I try to load up my page, I get the following error.
Warning (512): SQL Error: 1066: Not unique table/alias: 'ShoppingCart' [CORE/cake/libs/model/datasources/dbo_source.php, line 514] Now below is the line that generates the error in the shopping_carts_controller.php controller file. ** $this->ShoppingCart->unbindModel(array('belongsTo'=>array('User')));** Below are the definitions of the models that get used through association user.php: <?php class User extends AppModel { var $name = 'User';for php4 firstname'=>'/[a-z0-9 _-]{3,}$/i', var $hasMany = 'Purchase'; var $belongsTo = array('Country', 'State', 'PaymentMethod' , 'ShippingMethod'); } ?> =================== shopping_cart.php <?php class ShoppingCart extends AppModel { var $name = 'ShoppingCart'; var $belongsTo = array('User'); var $hasMany = array('ShoppingCartProduct' => array('className' => 'ShoppingCartProduct', 'dependent' => true)); } ?> ===================== shopping_cart_product.php <?php class ShoppingCartProduct extends AppModel { var $name = 'ShoppingCartProduct'; var $belongsTo = array('ShoppingCart', 'Product', 'Subproduct'); } ?> Now when I check the sql generated, I see something unusual which has driven me crazy. The SQL it generates is below. I have removed unnecessary fields in SQL to make the post smaller. SELECT ShoppingCart.id, ......., ShoppingCart.offer_id, ShoppingCart.subscription_id, ShoppingCart.persistent, ShoppingCart.decoration_id, ShoppingCart.coupon_code, ShoppingCart.coupon_price, Product.id, Product.active, Product.name, Product.description, Product.price, Product.quantity, Product.weight, Product.lead_time, Product.featured, ...... Product.user_design_id, Product.size_chart, Product.min_quantity, Product.allow_customization, Product.gender, Subproduct.id, Subproduct.product_id, Subproduct.name, Subproduct.price, Subproduct.weight, Subproduct.quantity, Subproduct.sort, Subproduct.created, Subproduct.modified, Subproduct.reorder_level, Subproduct.reorder_quantity, Subproduct.po_comments, Subproduct.reorder_date, Subproduct.product_code FROM shopping_cart_products AS **ShoppingCart** LEFT JOIN shopping_cart_products AS **ShoppingCart** ON (ShoppingCart.shopping_cart_id = ShoppingCart.id) LEFT JOIN products AS Product ON (ShoppingCart.product_id = Product.id) LEFT JOIN subproducts AS Subproduct ON (ShoppingCart.subproduct_id = Subproduct.id) WHERE ShoppingCart.session = 68900733 LIMIT 1 Question: Why is the ALIAS of the table shopping_cart_products coming up as ShoppingCart??? Any ideas? Any help with this greatly appreciated. -Samjoe -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php