PHPMyAdminで次のクエリを実行できますが、PHPのmysqlメソッドで実行すると、何らかの理由で構文エラーが発生します。
INSERT INTO product (model, stock_status_id, image, price, date_available, status, date_added, date_modified)
VALUES('SP44152', 5, 'data/products/SP44152-1.jpg', '18.04', '2012-06-18', 1, '2012-06-19 00:31:35', '2012-06-19 00:57:01');
SET @lastid = LAST_INSERT_ID();
INSERT INTO product_description (product_id, language_id, name, Description)
VALUES(@lastid, 1, 'Product item 1', 'Product Description');
INSERT INTO product_reward (product_id, customer_group_id, points)
VALUES(@lastid, 1, 0);
INSERT INTO product_to_category (product_id, category_id)
VALUES(@lastid, 67);
INSERT INTO product_to_store (product_id, store_id) VALUES(@lastid, 0);
私が得ているエラーコード:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @lastid = LAST_INSERT_ID(); INSERT INTO product_description (product_i' at line 3
;を削除してみました。各行の終わりから、フィールド「status」を削除してみました。これは、MYSQLでも使用できるものであることがわかっています。これの原因を特定するのに役立つインターネット上にはあまりないようです。
フィードバックは大歓迎です。