Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

OS 2.2 Problem with table prefixes


crispinw

Recommended Posts

I am new to OScommerce and recently asked for it to be installed on the same server as a busy database driven web service that I run. I knew long before installation that there could be a conflict with similar table names, so I checked with my hosting provider and they confirmed what I had read in the os documentation: I would be able to specify a table prefix i.e. "osc_" and there would be no problem.

 

Unfortunately, when I followed the web-based installation procedure and entered the information for the database connection, I was not asked to specify any prefix at all, instead the whole thing went from 0 to 100% without that step being offered or taken. As a result the installation DID overwrite a table in my existing service and brought it to a stand-still.

 

Fortunately I was able to arrange for a back up file to put in place and my main data service is back on its feet. OS now has a glitch and cannot cope with the table that does not match its expectations (in my case, the problem is with the countries). This is what the STORE area of the admin portal says:

 

1054 - Unknown column 'countries_name' in 'field list'

 

select countries_name from countries where countries_id = '223'

 

[TEP STOP]

 

Some bright spark knows what to do here? Is there a surgical tweak that can fix this and have OS run happily alongside my other service, a kind of retrospective prefix implementation or do I have to start from scratch with a different version that DOES check about prefixes before it overwrites precious files.

 

Thanks to any kind soul who takes pity on me!

Link to comment
Share on other sites

Is there a surgical tweak that can fix this and have OS run happily alongside my other service, a kind of retrospective prefix implementation or do I have to start from scratch with a different version that DOES check about prefixes before it overwrites precious files.

osC can handle that in principle (never really checked it fully) because the actual names of the database tables are saved in the file includes/database_tables.php (one in the catalog section, one in the admin section). The osC code always uses the defines so it shouldn't give a problem (unless a contribution does not use the defines...) You can change the define there to use osc_countries. Starts with:

  define('TABLE_COUNTRIES', 'osc_countries');

 

When the backup was re-loaded I suppose the countries table of osC was deleted. You would have to put back the table with the new name with:

CREATE TABLE `osc_countries` (
 `countries_id` int(11) NOT NULL auto_increment,
 `countries_name` varchar(64) NOT NULL,
 `countries_iso_code_2` char(2) NOT NULL,
 `countries_iso_code_3` char(3) NOT NULL,
 `address_format_id` int(11) NOT NULL,
 PRIMARY KEY  (`countries_id`),
 KEY `IDX_COUNTRIES_NAME` (`countries_name`)
);

Then find in the osC downloaded package, in the install folder the file oscommerce.sql. Line 831 to 1076 are the ones that hold the data on the countries:

INSERT INTO countries VALUES (1,'Afghanistan','AF','AFG','1');

Copy and paste those lines in a text file. Use search and replace (using a text editor) to change countries to osc_countries. Then copy and paste the create table code above before the INSERT INTO osc_countries VALUES (1,'Afghanistan','AF','AFG','1');

 

Save, and run it in phpMyAdmin as an sql file and you should be up and running.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...