Dan Cole Posted November 17, 2019 Share Posted November 17, 2019 I'm looking to update an old payment module Interac Email Money Transfer and it adds an orders status id to the database to set up an order status of "Waiting for Payment". Unfortunately it just adds the orders_status_id of 4 in a table update as follows: tep_db_query("insert into orders_status (orders_status_id, language_id, orders_status_name ) values ('4', '1', 'Waiting for payment')"); In my case I already have an orders_status_id of 4 in my database so it fails. Obviously I can easily fudge the id in my case but if I'm going to upload the contribution back to the community it'll cause problems for others so I'm wondering if there is a simple way to just have it add a unique id to the database or if I need to query the database for the last added id and go from there? That too is not a problem but this has me wondering if that is the best/simplest approach. Suggestions anyone? Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
♥ecartz Posted November 17, 2019 Share Posted November 17, 2019 tep_db_query("INSERT INTO orders_status (orders_status_id, language_id, orders_status_name ) SELECT MAX(orders_status_id) + 1, '1', 'Waiting for payment' FROM orders_status"); I believe that works. Test of course. First by running just the select in phpMyAdmin or similar and then try to write with it if the results are what you expect. Always back up before making changes. Link to comment Share on other sites More sharing options...
Dan Cole Posted November 17, 2019 Author Share Posted November 17, 2019 1 hour ago, ecartz said: tep_db_query("INSERT INTO orders_status (orders_status_id, language_id, orders_status_name ) SELECT MAX(orders_status_id) + 1, '1', 'Waiting for payment' FROM orders_status"); I believe that works. Test of course. First by running just the select in phpMyAdmin or similar and then try to write with it if the results are what you expect. That's awesome and works perfectly. Thanks Matt. I appreciate it. Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.